[Zodb-checkins] CVS: ZODB3/ZODB - FileStorage.py:1.109
Jeremy Hylton
jeremy@zope.com
Fri, 18 Oct 2002 14:01:40 -0400
Update of /cvs-repository/ZODB3/ZODB
In directory cvs.zope.org:/tmp/cvs-serv29934/ZODB
Modified Files:
FileStorage.py
Log Message:
Extend iterator() to include hint about backpointers.
The Record() object now has a data_txn attribute that is either None
or the id of the transaction that contains the data used by the
current record. Example: When transactionalUndo() modifies an object,
it typical creates a new data record that points at the transaction
before the undo. The new record contains the same logical data as the
record it refers to. (For consistency purposes, this is a stronger
claim than that the pickles in two different data records are the
same.)
Add a test of the new iterator() feature in TransactionalUndoStorage.
=== ZODB3/ZODB/FileStorage.py 1.108 => 1.109 ===
--- ZODB3/ZODB/FileStorage.py:1.108 Fri Oct 18 12:52:00 2002
+++ ZODB3/ZODB/FileStorage.py Fri Oct 18 14:01:39 2002
@@ -2098,18 +2098,27 @@
if vlen:
file.seek(vlen + 16, 1)
if plen != z64:
- return file.read(U64(plen)), serial, old
+ return file.read(U64(plen)), serial, old, tloc
back = file.read(8) # We got a back pointer!
def _loadBack(file, oid, back):
- data, serial, old = _loadBack_impl(file, oid, back)
+ data, serial, old, tloc = _loadBack_impl(file, oid, back)
return data, serial
def _loadBackPOS(file, oid, back):
"""Return position of data record for backpointer."""
- data, serial, old = _loadBack_impl(file, oid, back)
+ data, serial, old, tloc = _loadBack_impl(file, oid, back)
return old
+def _loadBackTxn(file, oid, back):
+ """Return data, serial, and txn id for backpointer."""
+ data, serial, old, stloc = _loadBack_impl(file, oid, back)
+ tloc = U64(stloc)
+ file.seek(tloc)
+ h = file.read(TRANS_HDR_LEN)
+ tid = h[:8]
+ return data, serial, tid
+
def _truncate(file, name, pos):
seek=file.seek
seek(0,2)
@@ -2346,6 +2355,7 @@
break
self._pos = pos + dlen
+ tid = None
if plen:
p = self._file.read(plen)
else:
@@ -2359,9 +2369,9 @@
# this.
p = None
else:
- p = _loadBack(self._file, oid, p)[0]
+ p, _s, tid = _loadBackTxn(self._file, oid, p)
- r = Record(oid, serial, version, p)
+ r = Record(oid, serial, version, p, tid)
return r
@@ -2370,7 +2380,7 @@
class Record(BaseStorage.DataRecord):
"""An abstract database record."""
def __init__(self, *args):
- self.oid, self.serial, self.version, self.data = args
+ self.oid, self.serial, self.version, self.data, self.data_txn = args
class UndoSearch: