[Zodb-checkins] SVN: ZODB/trunk/ Merge rev 27446 from 3.3 branch.

Tim Peters tim.one at comcast.net
Sat Sep 4 00:46:34 EDT 2004


Log message for revision 27448:
  Merge rev 27446 from 3.3 branch.
  
  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/trunk/NEWS.txt
  U   ZODB/trunk/src/ZODB/POSException.py
  U   ZODB/trunk/src/ZODB/utils.py


-=-
Modified: ZODB/trunk/NEWS.txt
===================================================================
--- ZODB/trunk/NEWS.txt	2004-09-04 04:44:43 UTC (rev 27447)
+++ ZODB/trunk/NEWS.txt	2004-09-04 04:46:34 UTC (rev 27448)
@@ -2,15 +2,6 @@
 =========================
 Release date: DD-MMM-YYYY
 
-BTrees
-------
-
-The BTrees __init__.py file is now just a comment.  It had been trying
-to set up support for (long gone) "int sets", and to import an old
-version of Zope's Interface package, which doesn't even ship with ZODB.
-The latter in particular created problems, at least clashing with
-PythonCAD's Interface package.
-
 Tools
 -----
 
@@ -65,6 +56,33 @@
 
 if using the default ThreadTransactionManager (see news for 3.3a3 below).
 
+BTrees
+------
+
+The BTrees __init__.py file is now just a comment.  It had been trying
+to set up support for (long gone) "int sets", and to import an old
+version of Zope's Interface package, which doesn't even ship with ZODB.
+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/trunk/src/ZODB/POSException.py
===================================================================
--- ZODB/trunk/src/ZODB/POSException.py	2004-09-04 04:44:43 UTC (rev 27447)
+++ ZODB/trunk/src/ZODB/POSException.py	2004-09-04 04:46:34 UTC (rev 27448)
@@ -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/trunk/src/ZODB/utils.py
===================================================================
--- ZODB/trunk/src/ZODB/utils.py	2004-09-04 04:44:43 UTC (rev 27447)
+++ ZODB/trunk/src/ZODB/utils.py	2004-09-04 04:46:34 UTC (rev 27448)
@@ -15,7 +15,6 @@
 import sys
 import time
 from struct import pack, unpack
-from types import StringType
 from binascii import hexlify
 import cPickle
 import cStringIO
@@ -34,6 +33,7 @@
            'tid_repr',
            'positive_id',
            'get_refs',
+           'readable_tid_repr',
           ]
 
 z64 = '\0'*8
@@ -89,7 +89,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.
@@ -104,6 +104,15 @@
 serial_repr = oid_repr
 tid_repr = serial_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