[Zope-CVS] CVS: Products/Ape/lib/apelib/zodb3 - connection.py:1.8.2.2

Shane Hathaway shane at zope.com
Thu Feb 26 18:50:24 EST 2004


Update of /cvs-repository/Products/Ape/lib/apelib/zodb3
In directory cvs.zope.org:/tmp/cvs-serv25862/zodb3

Modified Files:
      Tag: ape-fs-oid-branch
	connection.py 
Log Message:
Found and fixed a bug in writing to containers with ghosts.

Connection.commit() thought that ghosted objects loaded via
_persistent_load() were new objects rather than ghosts because they
had no serial.  This revealed that checking the serial is not right.

Instead, all ghosts of a live object are required to be in the
connection's cache; therefore, consult the cache to figure out whether
an object is new.  The new test passes with this change.



=== Products/Ape/lib/apelib/zodb3/connection.py 1.8.2.1 => 1.8.2.2 ===
--- Products/Ape/lib/apelib/zodb3/connection.py:1.8.2.1	Thu Feb 26 10:09:45 2004
+++ Products/Ape/lib/apelib/zodb3/connection.py	Thu Feb 26 18:49:53 2004
@@ -139,6 +139,7 @@
         obj._p_oid=oid
         obj._p_jar=self
         obj._p_changed=None
+        self.setSerial(obj, serial)
 
         self._cache[oid] = obj
         
@@ -261,8 +262,10 @@
             ext_refs = event.external
             if ext_refs:
                 for (ext_oid, ext_ref) in ext_refs:
-                    if self.getSerial(ext_ref) == HASH0:
-                        # New object
+                    assert ext_oid
+                    assert ext_ref is not None
+                    if self._cache.get(ext_oid, None) is not ext_ref:
+                        # New object or a bad reference
                         if ext_ref._p_jar is not None:
                             if ext_ref._p_jar is not self:
                                 raise InvalidObjectReference, (




More information about the Zope-CVS mailing list