Commit cd4c4e5c authored by Tim Peters's avatar Tim Peters

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.
parent d039df16
......@@ -50,6 +50,24 @@ 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
-----
......
......@@ -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 @@ class ConflictError(TransactionError):
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 @@ class ConflictError(TransactionError):
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:
......
......@@ -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 newTimeStamp(old=None,
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,6 +76,16 @@ def oid_repr(oid):
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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment