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
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.
For more information about ZODB, see the ZODB Wiki:
ZODB-Dev mailing list - ZODB-Dev@zope.org