[Zope-Checkins] CVS: ZODB3/ZODB - FileStorage.py:1.105.2.5
Jeremy Hylton
jeremy@zope.com
Tue, 5 Nov 2002 16:21:45 -0500
Update of /cvs-repository/ZODB3/ZODB
In directory cvs.zope.org:/tmp/cvs-serv7348/ZODB
Modified Files:
Tag: ZODB3-3_1-branch
FileStorage.py
Log Message:
Backport: Better fix for George Bailey events.
=== ZODB3/ZODB/FileStorage.py 1.105.2.4 => 1.105.2.5 ===
--- ZODB3/ZODB/FileStorage.py:1.105.2.4 Mon Oct 21 11:15:55 2002
+++ ZODB3/ZODB/FileStorage.py Tue Nov 5 16:21:44 2002
@@ -1045,18 +1045,20 @@
def _getVersion(self, oid, pos):
self._file.seek(pos)
- read=self._file.read
- h=read(DATA_HDR_LEN)
- doid,serial,sprev,stloc,vlen,splen = unpack(DATA_HDR, h)
+ h = self._file.read(DATA_HDR_LEN)
+ doid, serial, sprev, stloc, vlen, splen = unpack(DATA_HDR, h)
+ assert doid == oid
if vlen:
- h=read(16)
- return read(vlen), h[:8]
+ h = self._file.read(16)
+ return self._file.read(vlen), h[:8]
else:
- return '',''
+ return '', ''
def _getSerial(self, oid, pos):
- self._file.seek(pos+8)
- return self._file.read(8)
+ self._file.seek(pos)
+ h = self._file.read(16)
+ assert oid == h[:8]
+ return h[8:]
def _transactionalUndoRecord(self, oid, pos, serial, pre, version):
"""Get the indo information for a data record
@@ -1068,6 +1070,8 @@
"""
copy=1 # Can we just copy a data pointer
+
+ # First check if it is possible to undo this record.
tpos=self._tindex.get(oid, 0)
ipos=self._index.get(oid, 0)
tipos=tpos or ipos
@@ -1102,6 +1106,12 @@
# LoadBack gave us a key error. Bail.
raise UndoError
+ # Return the data that should be written in the undo record.
+ if not pre:
+ # There is no previous revision, because the object creation
+ # is being undone.
+ return '', 0, '', '', ipos
+
version, snv = self._getVersion(oid, pre)
if copy:
# we can just copy our previous-record pointer forward
@@ -1261,7 +1271,7 @@
tindex[oid] = here
here += odlen
- pos=pos+dlen
+ pos += dlen
if pos > tend:
raise UndoError, 'non-undoable transaction'
@@ -2138,6 +2148,7 @@
while 1:
old = U64(back)
if not old:
+ # If the backpointer is 0, the object does not currently exist.
raise POSKeyError(oid)
file.seek(old)
h = file.read(DATA_HDR_LEN)
@@ -2386,7 +2397,6 @@
prev = U64(sprev)
tloc = U64(stloc)
plen = U64(splen)
-
dlen = DATA_HDR_LEN + (plen or 8)
if vlen: