[Zope-Checkins] CVS: ZODB3/ZODB - FileStorage.py:1.117
Jeremy Hylton
jeremy@zope.com
Tue, 26 Nov 2002 17:48:43 -0500
Update of /cvs-repository/ZODB3/ZODB
In directory cvs.zope.org:/tmp/cvs-serv17137
Modified Files:
FileStorage.py
Log Message:
Provide much simpler version of getSerial().
=== ZODB3/ZODB/FileStorage.py 1.116 => 1.117 ===
--- ZODB3/ZODB/FileStorage.py:1.116 Mon Nov 18 18:17:40 2002
+++ ZODB3/ZODB/FileStorage.py Tue Nov 26 17:48:43 2002
@@ -573,31 +573,6 @@
if plen != z64: return read(U64(plen)), version, nv
return _loadBack(file, oid, read(8))[0], version, nv
- def getSerial(self, oid):
- self._lock_acquire()
- try:
- pos = self._index[oid]
- self._file.seek(pos)
- h = self._file.read(34)
- _oid = h[:8]
- if _oid != oid:
- raise CorruptedDataError, h
- vlen = unpack(">H", h[-2:])[0]
- if vlen:
- # If there is a version, find out its name and let
- # _load() do all the work. This is less efficient
- # than possible, because _load() will load the pickle
- # data. Being more efficient is too complicated.
- self._file.seek(24, 1) # skip plen, pnv, and pv
- version = self._file.read(vlen)
- pickledata, serial = self._load(oid, version,
- self._index, self._file)
- return serial
- return h[8:16]
- finally:
- self._lock_release()
-
-
def _load(self, oid, version, _index, file):
try:
pos = _index[oid]
@@ -1045,6 +1020,13 @@
else:
return '', ''
+ def getSerial(self, oid):
+ self._lock_acquire()
+ try:
+ return self._getSerial(oid, self._index[oid])
+ finally:
+ self._lock_release()
+
def _getSerial(self, oid, pos):
self._file.seek(pos)
h = self._file.read(16)
@@ -1222,8 +1204,7 @@
while pos < tend:
self._file.seek(pos)
h = self._file.read(DATA_HDR_LEN)
- oid, serial, sprev, stloc, vlen, splen = \
- struct.unpack(DATA_HDR, h)
+ oid, serial, sprev, stloc, vlen, splen = struct.unpack(DATA_HDR, h)
if failed(oid):
del failures[oid] # second chance!
plen = U64(splen)