[ZODB-Dev] Stability of ZODB.serialize.py?

mmillikan at vfa.com mmillikan at vfa.com
Wed Jan 28 14:35:27 EST 2004


serialize.py in CVS is much modified from the version included in
ZODB3-3.3a2. 

I am trying to persist some tree data structures of user
defined classes in ZODB. Is there a source of info with regard to the
required order of base classes when including persistent.Persistent
with other new and/or old style classes?

Some of my classes have many "special" methods defined on them:
__setitem__, __getitem__, __delitem__, __setattr__, __setstate__,
__getState__.

May these method overrides be used when designing classes to be stored
in ZODB? When should myobj.super.__specialmethod__ calls be made? Does
ZODB call them appropriately? I see places in the ZODB code where
object.__setstate__, for example, is called rather than invoking
'super'.

Sorry to ask so many unfocussed questions, but I have data structures
which work as required in memory and can be stored in shelve by
storing and retrieving the root object. Now, I'm trying to persist
them in a way allowing 'lazy' retrieval of portions of the data
structure. ZODB seems like the right tool for this. I've used zope off
and on for several years, read the zodb programming quide, and tried
the examples with success, and seen Jeremy Hylton's presentation at
LL2.

I'm trying to get a handle on whether I'm breaking some architectural
rules, running into a transitioning ZODB as it moves to new style
classes, or a little of both. One particular traceback is:

>>> get_transaction().commit()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/Users/markmillikan/app-archives/ZODB3-3.3a2/build/lib.darwin-7.2.0-Power_Macintosh-2.3/ZODB/Transaction.py", line 254, in commit
    self._cleanup(objects, ncommitted, jars, subjars)
  File "/Users/markmillikan/app-archives/ZODB3-3.3a2/build/lib.darwin-7.2.0-Power_Macintosh-2.3/ZODB/Transaction.py", line 233, in commit
    ncommitted += self._commit_objects(objects)
  File "/Users/markmillikan/app-archives/ZODB3-3.3a2/build/lib.darwin-7.2.0-Power_Macintosh-2.3/ZODB/Transaction.py", line 352, in _commit_objects
    jar.commit(o, self)
  File "/Users/markmillikan/app-archives/ZODB3-3.3a2/build/lib.darwin-7.2.0-Power_Macintosh-2.3/ZODB/Connection.py", line 306, in commit
    p = w.serialize(obj)
  File "/Users/markmillikan/app-archives/ZODB3-3.3a2/build/lib.darwin-7.2.0-Power_Macintosh-2.3/ZODB/serialize.py", line 114, in serialize
    return self._dump(getClassMetadata(obj), obj.__getstate__())
  File "/Users/markmillikan/app-archives/ZODB3-3.3a2/build/lib.darwin-7.2.0-Power_Macintosh-2.3/ZODB/serialize.py", line 123, in _dump
    self._p.dump(state)
TypeError: expected string or Unicode object, NoneType found

self._p is a cPickle.pickler object, so I coudn't chase down any more
details of what it was that was expecting a string, or what it was
that was None (it wasn't <state> which looked reasonable).

TIA





More information about the ZODB-Dev mailing list