[ZODB-Dev] None-persistent behaviour of BTree subclasses

Dieter Maurer dieter at handshake.de
Mon Apr 5 03:30:00 EDT 2004


pm5 at matilda.fiorile.org wrote at 2004-4-4 17:14 +0800:
> ...
>It seems that attributes of BTree subclasses are not saved. The
>following code raises an ``AssertionError: None != 'foo''' at the
>assertEqual line.  Descendants of Persistent (just change the definition
>of UserDefinedClass and run) perserves this attribute correctly.

"BTrees" have not been designed to be subclassed.

Apparently, their "__getstate__/__setstate__" only work
on the data maintained in "C" and not the class's "__dict__".

As the (complex) "_p_resolveConflict" implementation depends
on the "state" (as currently determined by "__getstate__/__setstate__")
it would probably be difficult to extend.

Your best bet is probably not to inherit from "BTrees" classes
but use instead delegation (which is much more tedious but probably
less tedious than extending the "BTrees" "__getstate__/__setstate__/
_p_resolveConflict").

-- 
Dieter



More information about the ZODB-Dev mailing list