[Zodb-checkins] CVS: StandaloneZODB/ZODB - POSException.py:1.7.94.5

Barry Warsaw barry@wooz.org
Mon, 17 Dec 2001 14:18:12 -0500


Update of /cvs-repository/StandaloneZODB/ZODB
In directory cvs.zope.org:/tmp/cvs-serv19780

Modified Files:
      Tag: StandaloneZODB-1_0-branch
	POSException.py 
Log Message:
ConflictError.__init__(): Fix so ZEO unittests pass.  `object' can
apparently be None or a string, so don't attempt to dig out _p_oid in
either case.

Jeremy, please proofread.

Also: get StringType and DictType out of the types module, and use a
more portable way to calculate __version__ from the CVS revision
string.


=== StandaloneZODB/ZODB/POSException.py 1.7.94.4 => 1.7.94.5 ===
 
 $Id$"""
-__version__='$Revision$'[11:-2]
+__version__ = '$Revision$'.split()[-2:][0]
 
 from string import join
+from types import StringType, DictType
 from ZODB import utils
 
-StringType=type('')
-DictType=type({})
-
 class POSError(Exception):
     """Persistent object system error
     """
@@ -45,6 +43,9 @@
         (old and new) of the object in conflict.  (Serial numbers are
         closely related [equal?] to transaction IDs; a ConflictError may
         be triggered by a serial number mismatch.)
+
+    oid and class_name may be None if the conflicting object wasn't a
+    persistent object.
     """
 
     def __init__(self, message=None, object=None, serials=None):
@@ -53,13 +54,13 @@
         else:
             self.message = message
 
-        if object is not None:
+        if object is None or isinstance(object, StringType):
+            self.oid = None
+            self.class_name = None
+        else:
             self.oid = object._p_oid
             klass = object.__class__
             self.class_name = klass.__module__ + "." + klass.__name__
-        else:
-            self.oid = None
-            self.class_name = None
 
         self.serials = serials