oddness in shelve module

Michael P. Soulier msoulier at digitaltorque.ca
Wed Jun 22 04:25:35 CEST 2005


I'm trying to add objects to a shelve db object via hash assignment, but
I'm getting an odd exception. 

Traceback (most recent call last):
  File "RemGui.py", line 117, in onMonitorButton
    self.startMonitoring()
  File "RemGui.py", line 163, in startMonitoring
    self.monitor()
  File "RemGui.py", line 181, in monitor
    self.db.store_sample(dbentry)
  File "C:\Documents and Settings\Michael Soulier\My
Documents\projects\rem\pysr
c\RemDBShelve.py", line 38, in store_sample
    self.db[sample.timestamp] = sample
TypeError: object does not support item assignment

The object itself is quite simple. 

I provide it below. If anyone can shed light on this, I'd appreciate it. 

Thanks,
Mike

class RemDBEntry(object):
    """This class represents one entry in the database. It stores a
    merging of all of the document types supplied by the server."""

    def __init__(self, timestamp):
        self.timestamp = timestamp
        self.procs = []
        self.partitions = []
        self.free = None
        self.uptime = None

    def merge(self, doc):
        """This method takes a RemDoc object and merges it with the
        current object."""
    
        if doc.type == 'uptime':
            self.uptime = doc.scalar
        elif doc.type == 'ps':
            self.procs = doc.children
        elif doc.type == 'siloShow':
            self.partitions = doc.children
        elif doc.type == 'siloShowMaxFree':
            self.free = doc.scalar
        else:
            raise AssertionError, "Unknown document type: %s" % doc.type


-- 
Michael P. Soulier <msoulier at digitaltorque.ca>
http://www.digitaltorque.ca
http://opag.ca      python -c 'import this'
Jabber: msoulier at digitaltorque.ca
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20050621/869f0558/attachment.sig>


More information about the Python-list mailing list