[Zodb-checkins] SVN: ZODB/branches/3.3/ Port from Zope 2.7 branch.

Tim Peters tim.one at comcast.net
Sat Sep 4 00:27:16 EDT 2004


Log message for revision 27446:
  Port from Zope 2.7 branch.
  
  Collector #1488 (TemporaryStorage -- going backward in time).
  
  This confusion was really due to that the detail on a ConflictError
  exception didn't make sense.
  


Changed:
  U   ZODB/branches/3.3/NEWS.txt
  U   ZODB/branches/3.3/src/ZODB/POSException.py
  U   ZODB/branches/3.3/src/ZODB/utils.py


-=-
Modified: ZODB/branches/3.3/NEWS.txt
===================================================================
--- ZODB/branches/3.3/NEWS.txt	2004-09-03 15:28:25 UTC (rev 27445)
+++ ZODB/branches/3.3/NEWS.txt	2004-09-04 04:27:14 UTC (rev 27446)
@@ -50,6 +50,24 @@
 The latter in particular created problems, at least clashing with
 PythonCAD's Interface package.
 
+POSException
+------------
+
+Collector #1488 (TemporaryStorage -- going backward in time).  This
+confusion was really due to that the detail on a ConflictError exception
+didn't make sense.  It called the current revision "was", and the old
+revision "now".  The detail is much more informative now.  For example,
+if the exception said:
+
+    ConflictError: database conflict error (oid 0xcb22,
+    serial was 0x03441422948b4399, now 0x034414228c3728d5)
+
+before, it now says:
+
+    ConflictError: database conflict error (oid 0xcb22,
+    serial this txn started with 0x034414228c3728d5 2002-04-14 20:50:32.863000,
+    serial currently committed 0x03441422948b4399 2002-04-14 20:50:34.815000)
+
 Tools
 -----
 

Modified: ZODB/branches/3.3/src/ZODB/POSException.py
===================================================================
--- ZODB/branches/3.3/src/ZODB/POSException.py	2004-09-03 15:28:25 UTC (rev 27445)
+++ ZODB/branches/3.3/src/ZODB/POSException.py	2004-09-04 04:27:14 UTC (rev 27446)
@@ -15,7 +15,7 @@
 
 $Id$"""
 
-from ZODB.utils import oid_repr, serial_repr
+from ZODB.utils import oid_repr, readable_tid_repr
 
 def _fmt_undo(oid, reason):
     s = reason and (": %s" % reason) or ""
@@ -48,8 +48,8 @@
       serials : (string, string)
         a pair of 8-byte packed strings; these are the serial numbers
         related to conflict.  The first is the revision of object that
-        is in conflict, the second is the revision of that the current
-        transaction read when it started.
+        is in conflict, the currently committed serial.  The second is
+        the revision the current transaction read when it started.
       data : string
         The database record that failed to commit, used to put the
         class name in the error message.
@@ -95,8 +95,11 @@
         if self.class_name:
             extras.append("class %s" % self.class_name)
         if self.serials:
-            extras.append("serial was %s, now %s" %
-                          tuple(map(serial_repr, self.serials)))
+            current, old = self.serials
+            extras.append("serial this txn started with %s" %
+                          readable_tid_repr(old))
+            extras.append("serial currently committed %s" %
+                          readable_tid_repr(current))
         if extras:
             return "%s (%s)" % (self.message, ", ".join(extras))
         else:

Modified: ZODB/branches/3.3/src/ZODB/utils.py
===================================================================
--- ZODB/branches/3.3/src/ZODB/utils.py	2004-09-03 15:28:25 UTC (rev 27445)
+++ ZODB/branches/3.3/src/ZODB/utils.py	2004-09-04 04:27:14 UTC (rev 27446)
@@ -15,7 +15,6 @@
 import sys
 import time
 from struct import pack, unpack
-from types import StringType
 from binascii import hexlify
 
 from persistent.TimeStamp import TimeStamp
@@ -64,7 +63,7 @@
 
 
 def oid_repr(oid):
-    if isinstance(oid, StringType) and len(oid) == 8:
+    if isinstance(oid, str) and len(oid) == 8:
         # Convert to hex and strip leading zeroes.
         as_hex = hexlify(oid).lstrip('0')
         # Ensure two characters per input byte.
@@ -77,7 +76,17 @@
         return repr(oid)
 
 serial_repr = oid_repr
+tid_repr = oid_repr
 
+# For example, produce
+#     '0x03441422948b4399 2002-04-14 20:50:34.815000'
+# for 8-byte string tid '\x03D\x14"\x94\x8bC\x99'.
+def readable_tid_repr(tid):
+    result = tid_repr(tid)
+    if isinstance(tid, str) and len(tid) == 8:
+        result = "%s %s" % (result, TimeStamp(tid))
+    return result
+
 # Addresses can "look negative" on some boxes, some of the time.  If you
 # feed a "negative address" to an %x format, Python 2.3 displays it as
 # unsigned, but produces a FutureWarning, because Python 2.4 will display



More information about the Zodb-checkins mailing list