[Zope-CVS] CVS: Products/Ape/lib/apelib/tests - zope2testbase.py:1.7.2.2

Shane Hathaway shane at zope.com
Thu Feb 26 18:49:54 EST 2004


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

Modified Files:
      Tag: ape-fs-oid-branch
	zope2testbase.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/tests/zope2testbase.py 1.7.2.1 => 1.7.2.2 ===
--- Products/Ape/lib/apelib/tests/zope2testbase.py:1.7.2.1	Wed Feb 25 22:08:56 2004
+++ Products/Ape/lib/apelib/tests/zope2testbase.py	Thu Feb 26 18:49:54 2004
@@ -635,3 +635,26 @@
             self.assert_(app._p_mtime < now + 10)
         finally:
             conn.close()
+
+
+    def testWriteWithGhosts(self):
+        # It should be possible to write a container even if one
+        # or more of its subobjects are ghosts.
+        conn = self.db.open()
+        try:
+            root = conn.root()
+            root['foo'] = 1
+            f = Folder()
+            f.id = 'bar'
+            root['bar'] = f
+            get_transaction().commit()
+            conn2 = self.db.open()
+            try:
+                root2 = conn2.root()
+                root2['foo'] = 2
+                self.assertEqual(root2['bar']._p_changed, None)
+                get_transaction().commit()
+            finally:
+                conn2.close()
+        finally:
+            conn.close()




More information about the Zope-CVS mailing list