[Zodb-checkins] CVS: Zope3/lib/python/ZODB - FileStorage.py:1.105
Jeremy Hylton
jeremy@zope.com
Tue, 26 Nov 2002 17:49:33 -0500
Update of /cvs-repository/Zope3/lib/python/ZODB
In directory cvs.zope.org:/tmp/cvs-serv17294
Modified Files:
FileStorage.py
Log Message:
Provide much simpler version of getSerial().
=== Zope3/lib/python/ZODB/FileStorage.py 1.104 => 1.105 ===
--- Zope3/lib/python/ZODB/FileStorage.py:1.104 Tue Nov 26 12:41:21 2002
+++ Zope3/lib/python/ZODB/FileStorage.py Tue Nov 26 17:49:33 2002
@@ -582,31 +582,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]
@@ -1055,6 +1030,13 @@
return self._file.read(vlen), h[:8]
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)