[Zodb-checkins] SVN: ZODB/branches/3.8/ Fixed a bug that could cause InvalidObjectReference errors

Jim Fulton jim at zope.com
Thu Jul 24 14:42:35 EDT 2008


Log message for revision 88798:
  Fixed a bug that could cause InvalidObjectReference errors
  for objects that were explicitly added to a database if the object
  was modified after a savepoint that added the object.
  

Changed:
  U   ZODB/branches/3.8/NEWS.txt
  U   ZODB/branches/3.8/src/ZODB/Connection.py
  U   ZODB/branches/3.8/src/ZODB/tests/testcrossdatabasereferences.py

-=-
Modified: ZODB/branches/3.8/NEWS.txt
===================================================================
--- ZODB/branches/3.8/NEWS.txt	2008-07-24 18:17:20 UTC (rev 88797)
+++ ZODB/branches/3.8/NEWS.txt	2008-07-24 18:42:32 UTC (rev 88798)
@@ -5,6 +5,11 @@
 
 Bugs Fixed:
 
+- (beta 6) Fixed a bug that could cause InvalidObjectReference errors
+  for objects that were explicitly added to a database if the object
+  was modified after a savepoint that added the object.
+
+
 - (beta 5) Fixed several bugs that caused ZEO cache corruption when connecting
   to servers. These bugs affected both persistent and non-persistent caches. 
 

Modified: ZODB/branches/3.8/src/ZODB/Connection.py
===================================================================
--- ZODB/branches/3.8/src/ZODB/Connection.py	2008-07-24 18:17:20 UTC (rev 88797)
+++ ZODB/branches/3.8/src/ZODB/Connection.py	2008-07-24 18:42:32 UTC (rev 88798)
@@ -594,7 +594,14 @@
             oid = obj._p_oid
             serial = getattr(obj, "_p_serial", z64)
 
-            if serial == z64:
+            if ((serial == z64)
+                and
+                ((self._savepoint_storage is None)
+                 or (oid not in self._savepoint_storage.creating)
+                 or self._savepoint_storage.creating[oid]
+                 )
+                ):
+                
                 # obj is a new object
 
                 # Because obj was added, it is now in _creating, so it

Modified: ZODB/branches/3.8/src/ZODB/tests/testcrossdatabasereferences.py
===================================================================
--- ZODB/branches/3.8/src/ZODB/tests/testcrossdatabasereferences.py	2008-07-24 18:17:20 UTC (rev 88797)
+++ ZODB/branches/3.8/src/ZODB/tests/testcrossdatabasereferences.py	2008-07-24 18:42:32 UTC (rev 88798)
@@ -146,6 +146,32 @@
 
 """
 
+def test_explicit_adding_with_savepoint2():
+    """
+
+    >>> import ZODB.tests.util, transaction, persistent
+    >>> databases = {}
+    >>> db1 = ZODB.tests.util.DB(databases=databases, database_name='1')
+    >>> db2 = ZODB.tests.util.DB(databases=databases, database_name='2')
+    >>> tm = transaction.TransactionManager()
+    >>> conn1 = db1.open(transaction_manager=tm)
+    >>> conn2 = conn1.get_connection('2')
+    >>> z = MyClass()
+
+    >>> conn1.root()['z'] = z
+    >>> conn1.add(z)
+    >>> s = tm.savepoint()
+    >>> conn2.root()['z'] = z
+    >>> z.x = 1
+    >>> tm.commit()
+    >>> z._p_jar.db().database_name
+    '1'
+    
+    >>> db1.close()
+    >>> db2.close()
+
+"""
+
 def tearDownDbs(test):
     test.globs['db1'].close()
     test.globs['db2'].close()



More information about the Zodb-checkins mailing list