loading an object's state

Jeremy Hylton <[email protected]> Thu, 11 Jul 2002 19:30:54 -0400
Newsgroups gmane.comp.python.zope.zodb4
Message-ID <[email protected]>
The code to unghostify an object inside the Persistent getattr hook
looks like this:

    if ((s_name[0] != '_')
	|| ((strncmp(s_name, "_p_", 3) != 0)
	    && (strcmp(s_name, "__dict__") != 0))) {
	if (self->po_state == GHOST) {
	    self->po_state = CHANGED; 
	    if (_PyPersist_Load((PyPersistBaseObject *)self) == NULL) {
		call_p_deactivate(self);
		self->po_state = GHOST;
		return NULL;
	    } else
		self->po_state = UPTODATE;
	}
	_PyPersist_SetATime((PyPersistBaseObject *)self);
    }

It's very similar to the code in Zope2 to accomplish the same thing.

Do you know what it changes the state from GHOST to CHANGED before
loading the state?  The Zope2 code does the same thing.  It seems
significant, but I can't remember (if I ever knew) why it is
necessary.

Jeremy