[Zope-Checkins] CVS: Zope2 - ConflictResolution.py:1.1.2.3
Jim Fulton
jim@digiciool.com
Wed, 14 Mar 2001 20:57:50 -0500 (EST)
Update of /cvs-repository/Zope2/lib/python/ZODB
In directory korak:/tmp/cvs-serv10580
Modified Files:
Tag: Catalog-BTrees-Integration
ConflictResolution.py
Log Message:
Added error-raising __getstate__ on persistent reference objects to
make sure they aren't accidently pickled.
Refined code for detecting classes that don't support conflict
resolution.
--- Updated File ConflictResolution.py in package Zope2 --
--- ConflictResolution.py 2001/03/14 16:46:45 1.1.2.2
+++ ConflictResolution.py 2001/03/15 01:57:49 1.1.2.3
@@ -84,8 +84,9 @@
##############################################################################
from cStringIO import StringIO
from cPickle import Unpickler, Pickler
+import sys
-#import sys, traceback
+#import traceback
bad_classes={}
bad_class=bad_classes.has_key
@@ -112,6 +113,9 @@
def __repr__(self):
return "PR(%s %s)" % (id(self), self.data)
+ def __getstate__(self):
+ raise "Can't pickle PersistentReference"
+
class PersistentReferenceFactory:
data=None
@@ -153,13 +157,14 @@
#sys.stderr.write(' b%s ' % class_tuple[1]); sys.stderr.flush()
return 0
+ newstate=unpickler.load()
+ klass=_classFactory(class_tuple[0], class_tuple[1])
+ klass._p_resolveConflict
+ inst=klass.__basicnew__()
+
try:
- newstate=unpickler.load()
- klass=_classFactory(class_tuple[0], class_tuple[1])
- klass._p_resolveConflict
- inst=klass.__basicnew__()
resolve=inst._p_resolveConflict
- except:
+ except AttributeError:
bad_classes[class_tuple]=1
#traceback.print_exc()
#sys.stderr.write(' b%s ' % class_tuple[1]); sys.stderr.flush()
@@ -189,6 +194,8 @@
#print '='*70
#traceback.print_exc()
+
#sys.stderr.write(' c%s ' % class_tuple[1]); sys.stderr.flush()
+
return 0