[Zope-Checkins] CVS: ZODB3/ZODB - ConflictResolution.py:1.13
Jeremy Hylton
jeremy@zope.com
Thu, 15 Aug 2002 11:48:56 -0400
Update of /cvs-repository/ZODB3/ZODB
In directory cvs.zope.org:/tmp/cvs-serv7183
Modified Files:
ConflictResolution.py
Log Message:
Frontport bug fixes in ConflictResolution to the trunk.
The main idea in the bug fix is to recover more gracefully when
something goes wrong trying to load classes for conflict resolution.
XXX This accidentally got checked in on the Zope 2.5 branch first.
=== ZODB3/ZODB/ConflictResolution.py 1.12 => 1.13 ===
--- ZODB3/ZODB/ConflictResolution.py:1.12 Wed Aug 14 18:07:09 2002
+++ ZODB3/ZODB/ConflictResolution.py Thu Aug 15 11:48:55 2002
@@ -15,6 +15,7 @@
from cPickle import Unpickler, Pickler
from ZODB.POSException import ConflictError
+import zLOG
bad_classes = {}
@@ -70,20 +71,29 @@
return None
return object.data
+def load_class(class_tuple):
+ try:
+ klass = _classFactory(class_tuple[0], class_tuple[1])
+ except (ImportError, AttributeError):
+ zLOG.LOG("Conflict Resolution", zLOG.BLATHER,
+ "Unable to load class", error=sys.exc_info())
+ bad_class[class_tuple] = 1
+ return None
+ return klass
+
def tryToResolveConflict(self, oid, committedSerial, oldSerial, newpickle,
committedData=''):
- #class_tuple, old, committed, newstate = ('',''), 0, 0, 0
+ # class_tuple, old, committed, newstate = ('',''), 0, 0, 0
try:
+ prfactory = PersistentReferenceFactory()
file = StringIO(newpickle)
unpickler = Unpickler(file)
- prfactory = PersistentReferenceFactory()
unpickler.persistent_load = prfactory.persistent_load
class_tuple = unpickler.load()[0]
if bad_class(class_tuple):
return 0
-
newstate = unpickler.load()
- klass = _classFactory(class_tuple[0], class_tuple[1])
+ klass = load_class(class_tuple)
inst = klass.__basicnew__()
try: