[ZODB-Dev] Re: Why does this useage of __setstate__ fail?
Dieter Maurer
dieter at handshake.de
Thu Jan 17 17:39:13 EST 2008
Tres Seaver wrote at 2008-1-17 01:30 -0500:
> ...
>Mika, David P (GE, Research) wrote:
>
>>> Can someone explain why the test below (test_persistence) is failing?
>>> I am adding an attribute after object creation with __setstate__, but
>>> I can't get the new attribute to persist.
>
>You are mutating the object *inside* your __setstate__: the ZODB
>persistence machinery clears the '_p_changed' flag after you *exit* from
>'__setstate__': the protocol is not intended to support a persistent
>"write-on-read".
When I remember right, newer ZODB versions allow the "__setstate__"
implementation to tell whether "_p_changed" should or should not be
cleared (default: cleared).
Tim Peters added this feature to support the frequent use case,
that "__setstate__" is used for object migration.
--
Dieter
More information about the ZODB-Dev
mailing list