[Zodb-checkins] CVS: StandaloneZODB/ZODB - FileStorage.py:1.71.2.3
Jeremy Hylton
jeremy@zope.com
Wed, 10 Oct 2001 10:05:36 -0400
Update of /cvs-repository/StandaloneZODB/ZODB
In directory cvs.zope.org:/tmp/cvs-serv8389
Modified Files:
Tag: jeremy-Standby-branch
FileStorage.py
Log Message:
lastSerial() returns None when the object is not found
=== StandaloneZODB/ZODB/FileStorage.py 1.71.2.2 => 1.71.2.3 ===
def lastSerial(self, oid):
- """Return last serialno committed for object oid."""
- pos = self._index[oid]
+ """Return last serialno committed for object oid.
+
+ If there is no serialno for this oid -- which can only occur
+ if it is a new object -- return None.
+ """
+ try:
+ pos = self._index[oid]
+ except KeyError:
+ return None
self._file.seek(pos)
# first 8 bytes are oid, second 8 bytes are serialno
h = self._file.read(16)
@@ -2042,6 +2049,8 @@
file.seek(0,2)
self._file_size=file.tell()
self._pos=4L
+ assert start is None or isinstance(start, StringType)
+ assert stop is None or isinstance(stop, StringType)
if start:
self._skip_to_start(start)
self._stop = stop
@@ -2051,13 +2060,13 @@
# checks.
self._file.seek(self._pos)
while 1:
- h = self._file.read(8)
- if len(h) < 8:
+ h = self._file.read(16)
+ if len(h) < 16:
return
tid, stl = unpack(">8s8s", h)
tl = U64(stl)
if tid >= start:
- self._file.seek(-8, 1)
+ self._file.seek(-16, 1)
return
self._file.seek(tl - 8)
rtl = self._file.read(8)
@@ -2072,6 +2081,7 @@
read=file.read
pos=self._pos
+ LOG("ZODB FS", -100, "next(%d)" % index)
while 1:
# Read the transaction record
seek(pos)
@@ -2120,7 +2130,11 @@
warn('%s has invalid transaction header at %s', name, pos)
break
- if self._stop is not None and tid >= self._stop:
+ if self._stop is not None:
+ LOG("ZODB FS", -100,
+ ("tid %s > stop %s ? %d" %
+ (repr(tid), repr(self._stop), tid > self._stop)))
+ if self._stop is not None and tid > self._stop:
raise IndexError, index
tpos=pos