[Zodb-checkins] SVN: ZODB/branches/3.10/src/ Bug Fixed
Jim Fulton
jim at zope.com
Fri Nov 18 22:33:14 UTC 2011
Log message for revision 123429:
Bug Fixed
Conflict resolution failed when state included cross-database
persistent references with classes that couldn't be imported.
Changed:
U ZODB/branches/3.10/src/CHANGES.txt
U ZODB/branches/3.10/src/ZODB/ConflictResolution.py
U ZODB/branches/3.10/src/ZODB/tests/testconflictresolution.py
-=-
Modified: ZODB/branches/3.10/src/CHANGES.txt
===================================================================
--- ZODB/branches/3.10/src/CHANGES.txt 2011-11-18 18:20:03 UTC (rev 123428)
+++ ZODB/branches/3.10/src/CHANGES.txt 2011-11-18 22:33:13 UTC (rev 123429)
@@ -2,6 +2,15 @@
Change History
================
+3.10.5 (2011-11-19)
+===================
+
+Bugs Fixed
+----------
+
+- Conflict resolution failed when state included cross-database
+ persistent references with classes that couldn't be imported.
+
3.10.4 (2011-11-17)
===================
Modified: ZODB/branches/3.10/src/ZODB/ConflictResolution.py
===================================================================
--- ZODB/branches/3.10/src/ZODB/ConflictResolution.py 2011-11-18 18:20:03 UTC (rev 123428)
+++ ZODB/branches/3.10/src/ZODB/ConflictResolution.py 2011-11-18 22:33:13 UTC (rev 123429)
@@ -140,7 +140,10 @@
# or persistent weakref: (oid, database_name)
# else it is a weakref: reference_type
if reference_type == 'm':
- self.database_name, self.oid, _ = data[1]
+ self.database_name, self.oid, klass = data[1]
+ if isinstance(klass, BadClass):
+ # see above wrt BadClass
+ data[1] = self.database_name, self.oid, klass.args
elif reference_type == 'n':
self.database_name, self.oid = data[1]
elif reference_type == 'w':
Modified: ZODB/branches/3.10/src/ZODB/tests/testconflictresolution.py
===================================================================
--- ZODB/branches/3.10/src/ZODB/tests/testconflictresolution.py 2011-11-18 18:20:03 UTC (rev 123428)
+++ ZODB/branches/3.10/src/ZODB/tests/testconflictresolution.py 2011-11-18 22:33:13 UTC (rev 123429)
@@ -237,9 +237,61 @@
"""
+def resolve_even_when_xdb_referenced_classes_are_absent():
+ """Cross-database persistent refs!
+ >>> class P(persistent.Persistent):
+ ... pass
+ >>> databases = {}
+ >>> db = ZODB.DB('t.fs', databases=databases, database_name='')
+ >>> _ = ZODB.DB('o.fs', databases=databases, database_name='o')
+ >>> storage = db.storage
+ >>> conn = db.open()
+ >>> conn.root.x = Resolveable()
+ >>> transaction.commit()
+ >>> oid = conn.root.x._p_oid
+ >>> serial = conn.root.x._p_serial
+ >>> p = P(); conn.get_connection('o').add(p)
+ >>> conn.root.x.a = p
+ >>> transaction.commit()
+ >>> aid = conn.root.x.a._p_oid
+ >>> serial1 = conn.root.x._p_serial
+
+ >>> del conn.root.x.a
+ >>> p = P(); conn.get_connection('o').add(p)
+ >>> conn.root.x.b = p
+ >>> transaction.commit()
+ >>> serial2 = conn.root.x._p_serial
+
+ >>> del p
+
+Bwahaha:
+
+ >>> P_aside = P
+ >>> del P
+
+Now, even though we can't import P, we can still resolve the conflict:
+
+ >>> p = storage.tryToResolveConflict(
+ ... oid, serial1, serial, storage.loadSerial(oid, serial2))
+
+And load the pickle:
+
+ >>> conn2 = db.open()
+ >>> conn2o = conn2.get_connection('o')
+ >>> P = P_aside
+ >>> p = conn2._reader.getState(p)
+ >>> sorted(p), p['a'] is conn2o.get(aid), p['b'] is conn2.root.x.b
+ (['a', 'b'], True, True)
+
+ >>> isinstance(p['a'], P) and isinstance(p['b'], P)
+ True
+
+ >>> db.close()
+ """
+
def test_suite():
return unittest.TestSuite([
manuel.testing.TestSuite(
More information about the Zodb-checkins
mailing list