[Zope-dev] Help: __getstate__ overriding
Tim Peters
tim.one at comcast.net
Sun May 30 14:49:18 EDT 2004
[Dieter Maurer]
> I think, this is a ZODB buglet:
>
> It should set "_p_changed = 0" before it calls "__setstate__"
> and not afterwards...
I don't know; Jim (or Jeremy) may know the reasoning here, but I don't.
Activation currently sets the state to changed *before* calling __setstate__
too. A comment says this is to prevent recursively calling _PyPersist_Load,
and that makes sense to me, else unbounded recursion could occur.
Given this abuse of _p_changed, and that the purpose of activating a ghost
is to transition it to the up-to-date state, making mutations to the
persistent state inside __setstate__ seems hard to accommodate.
On ZODB head, Jeremy also documented that __setstate__ can't affect the
persistent state (in persistent/interfaces.py's IPersistent). Whether this
is deliberate design, or a consequence of the current implementation, I
can't say.
More information about the Zope-Dev
mailing list