[Zodb-checkins] CVS: Zope3/src/persistence - persistence.c:1.18
Jeremy Hylton
jeremy at zope.com
Mon Jun 30 12:53:19 EDT 2003
Update of /cvs-repository/Zope3/src/persistence
In directory cvs.zope.org:/tmp/cvs-serv13557/persistence
Modified Files:
persistence.c
Log Message:
Fix for setting _p_changed on a ghost: Ignore it.
This is a weird corner case. The old behavior was definitely wrong --
mark object as changed but do not register with data manager. The new
behavior is to ignore the assignment, but it might be better to raise
an exception.
=== Zope3/src/persistence/persistence.c 1.17 => 1.18 ===
--- Zope3/src/persistence/persistence.c:1.17 Tue May 20 15:01:39 2003
+++ Zope3/src/persistence/persistence.c Mon Jun 30 11:52:48 2003
@@ -354,22 +354,14 @@
return -1;
newstate = bool ? CHANGED_TRUE : CHANGED_FALSE;
- /* XXX I think the cases below cover all the transitions of
- interest. We should really extend the interface / documentation
- with a state transition diagram.
- */
- if (self->po_state == GHOST) {
- if (newstate == CHANGED_TRUE || newstate == CHANGED_FALSE) {
- /* Turn a ghost into a real object. */
- self->po_state = CHANGED;
- if (!_PyPersist_Load((PyPersistObject *)self))
- { self->po_state = GHOST; return -1; }
- if (newstate == CHANGED_TRUE)
- self->po_state = CHANGED;
- else
- self->po_state = UPTODATE;
- }
- } else if (newstate == CHANGED_TRUE) {
+ if (self->po_state == GHOST)
+ /* If the object is a ghost, it makes no sense to try to mark
+ it as changed. It's state must be loaded first.
+
+ XXX Should it raise an exception? It doesn't in ZODB3.
+ */
+ return 0;
+ else if (newstate == CHANGED_TRUE) {
/* Mark an up-to-date object as changed. */
if (self->po_state == UPTODATE) {
if (!_PyPersist_RegisterDataManager((PyPersistObject *)self))
More information about the Zodb-checkins
mailing list