Commit 90321e29 authored by Tim Peters's avatar Tim Peters

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.
parent c83cf55d
......@@ -2,15 +2,6 @@ What's new in ZODB3 3.3 ?
=========================
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 @@ the relevant transaction manager instead. For example,
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
-----
......
......@@ -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
import cPickle
import cStringIO
......@@ -34,6 +33,7 @@ __all__ = ['z64',
'tid_repr',
'positive_id',
'get_refs',
'readable_tid_repr',
]
z64 = '\0'*8
......@@ -89,7 +89,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.
......@@ -104,6 +104,15 @@ def oid_repr(oid):
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
......
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