[Zope3-checkins] CVS: Zope3/src/zodb - conflict.py:1.3

Jeremy Hylton jeremy@zope.com
Thu, 9 Jan 2003 13:16:49 -0500


Update of /cvs-repository/Zope3/src/zodb
In directory cvs.zope.org:/tmp/cvs-serv23546/zodb

Modified Files:
	conflict.py 
Log Message:
Collector #121:  ConflictResolvingStorage doesn't with builtin
_p_resolveConfict

Add several tests to test_conflict that test integration through zodb.
These tests should be backported to ZODB3.


=== Zope3/src/zodb/conflict.py 1.2 => 1.3 ===
--- Zope3/src/zodb/conflict.py:1.2	Wed Dec 25 09:12:16 2002
+++ Zope3/src/zodb/conflict.py	Thu Jan  9 13:16:16 2003
@@ -116,6 +116,14 @@
         else:
             return resolve
 
+def get_self(method):
+    # a method defined in Python
+    self = getattr(method, "im_self", None)
+    if self is not None:
+        return self
+    # a builtin method
+    return getattr(method, "__self__")
+
 class ConflictResolvingStorage:
     "Mix-in class that provides conflict resolution handling for storages"
 
@@ -146,5 +154,5 @@
             return None
 
         writer = ObjectWriter()
-        obj = ResolvedObjectAdapter(resolve.im_self, resolved)
+        obj = ResolvedObjectAdapter(get_self(resolve), resolved)
         return writer.getState(obj)