[Zodb-checkins] SVN: ZODB/trunk/src/ZODB/ Bug Fixed: Packing failed for databases containing cross-database references.

Jim Fulton jim at zope.com
Fri Aug 29 08:44:37 EDT 2008


Log message for revision 90584:
  Bug Fixed: Packing failed for databases containing cross-database references.
  

Changed:
  U   ZODB/trunk/src/ZODB/serialize.py
  U   ZODB/trunk/src/ZODB/tests/PackableStorage.py

-=-
Modified: ZODB/trunk/src/ZODB/serialize.py
===================================================================
--- ZODB/trunk/src/ZODB/serialize.py	2008-08-29 12:44:34 UTC (rev 90583)
+++ ZODB/trunk/src/ZODB/serialize.py	2008-08-29 12:44:36 UTC (rev 90584)
@@ -605,17 +605,14 @@
         obj.__setstate__(state)
 
 
-oid_loaders = {
-    'w': lambda oid: None,
-    }
-
 def referencesf(p, oids=None):
     """Return a list of object ids found in a pickle
 
     A list may be passed in, in which case, information is
     appended to it.
 
-    Weak references are not included.
+    Only ordinary internal references are included.
+    Weak and multi-database references are not included.
     """
 
     refs = []
@@ -636,16 +633,10 @@
         elif isinstance(reference, str):
             oid = reference
         else:
-            try:
-                reference_type, args = reference
-            except ValueError:
-                # weakref
-                continue
-            else:
-                oid = oid_loaders[reference_type](*args)
+            assert isinstance(reference, list)
+            continue
 
-        if oid:
-            oids.append(oid)
+        oids.append(oid)
     
     return oids
 
@@ -678,15 +669,9 @@
         elif isinstance(reference, str):
             data = reference, None
         else:
-            try:
-                reference_type, args = reference
-            except ValueError:
-                # weakref
-                continue
-            else:
-                data = oid_klass_loaders[reference_type](*args)
+            assert isinstance(reference, list)
+            continue
 
-        if data:
-            result.append(data)
+        result.append(data)
     
     return result

Modified: ZODB/trunk/src/ZODB/tests/PackableStorage.py
===================================================================
--- ZODB/trunk/src/ZODB/tests/PackableStorage.py	2008-08-29 12:44:34 UTC (rev 90583)
+++ ZODB/trunk/src/ZODB/tests/PackableStorage.py	2008-08-29 12:44:36 UTC (rev 90584)
@@ -38,6 +38,8 @@
 
 from ZODB.tests.MTStorage import TestThread
 
+import ZODB.tests.util
+
 ZERO = '\0'*8
 
 
@@ -311,6 +313,24 @@
                 pass
         it.close()
 
+    def checkPackWithMultiDatabaseReferences(self):
+        databases = {}
+        db = DB(self._storage, databases=databases, database_name='')
+        otherdb = ZODB.tests.util.DB(databases=databases, database_name='o')
+        conn = db.open()
+        root = conn.root()
+        root[1] = C()
+        transaction.commit()
+        del root[1]
+        transaction.commit()
+        root[2] = conn.get_connection('o').root()
+        transaction.commit()
+        db.pack(time.time()+1)
+        assert(len(self._storage) == 1)
+                
+        
+        
+
 class PackableUndoStorage(PackableStorageBase):
 
     def checkPackAllRevisions(self):
@@ -705,3 +725,4 @@
 
     def elapsed_millis(self):
         return int((time.time() - self.start_time) * 1000)
+



More information about the Zodb-checkins mailing list