[Zope3-checkins] CVS: ZODB4/Persistence - cPersistence.c:1.14

Jeremy Hylton jeremy@zope.com
Thu, 18 Jul 2002 18:09:51 -0400


Update of /cvs-repository/ZODB4/Persistence
In directory cvs.zope.org:/tmp/cvs-serv18909

Modified Files:
	cPersistence.c 
Log Message:
Fix the setattr logic for registering an object with its data manager.

If setattr was called on a ghost, it was not registered with the data
manager, which in turn registers it with the transaction.  As a
result, modifications to ghosts could be lost.

Reported by Neil Schemenauer.



=== ZODB4/Persistence/cPersistence.c 1.13 => 1.14 ===
 	    }
 	    if (_PyPersist_Load((PyPersistBaseObject *)self) == NULL)
 		return -1;
-	} else if (self->po_state == UPTODATE && self->po_dm)
-	    if (!_PyPersist_RegisterDataManager((PyPersistBaseObject *)self))
-		return -1;
+	}
+	/* If the object is marked as UPTODATE then it must be
+	   registered as modified.  If it was just unghosted, it
+	   will be in the UPTODATE state.  
+
+	   If it's in the changed state, it should already be registered.
+	   
+	   XXX What if it's in the sticky state?
+	*/
+	if (self->po_state == UPTODATE && self->po_dm &&
+	    !_PyPersist_RegisterDataManager((PyPersistBaseObject *)self))
+	    return -1;
 
 	if (self->po_dm && self->po_oid) {
 	    self->po_state = CHANGED;