persistence and __setstate__

Florent Guillaume <[email protected]> Wed, 31 Jul 2002 13:54:19 +0000 (UTC)
Newsgroups gmane.comp.python.zope.zodb4
Organization Nuxeo
Message-ID <[email protected]>
I'll repost this here, as people are probably more knowledgeable.


Consider this recent explanation that was added:

--- cPersistence.c      11 Jul 2002 15:52:06 -0000      1.9
+++ cPersistence.c      12 Jul 2002 12:49:01 -0000      1.10
@@ -468,6 +468,14 @@
        || ((strncmp(s_name, "_p_", 3) != 0)
            && (strcmp(s_name, "__dict__") != 0))) {
        if (self->po_state == GHOST) {
+           /* Prevent the object from being registered as changed.
+
+              If the object is changed while it is being unghostified,
+              it should not be registered with the data manager as
+              a changed object.  The easiest way to prevent this is
+              to mark it as already changed, which implies it is
+              already registered. 
+           */
            self->po_state = CHANGED;
            if (_PyPersist_Load((PyPersistBaseObject *)self) == NULL) {
                call_p_deactivate(self);



Doesn't that mean that if an object is changed during its __setstate__
but not after, those changes won't get persisted (because just after
__setstate__ the object reverts to UPTODATE) ?

So won't all objects that upgrade themselves in __setstate__ keep being
upgraded whenever they are reloaded, until they are modified from
outside __setstate__ ?

Florent

-- 
Florent Guillaume, Nuxeo (Paris, France)
+33 1 40 33 79 87  http://nuxeo.com  mailto:[email protected]