[Zope-Checkins] CVS: ZODB3/ZODB - FileStorage.py:1.105.2.8
Jeremy Hylton
jeremy@zope.com
Tue, 26 Nov 2002 18:03:24 -0500
Update of /cvs-repository/ZODB3/ZODB
In directory cvs.zope.org:/tmp/cvs-serv19541
Modified Files:
Tag: ZODB3-3_1-branch
FileStorage.py
Log Message:
Backport from the trunk: Provide much simpler version of getSerial().
=== ZODB3/ZODB/FileStorage.py 1.105.2.7 => 1.105.2.8 ===
--- ZODB3/ZODB/FileStorage.py:1.105.2.7 Fri Nov 15 12:18:55 2002
+++ ZODB3/ZODB/FileStorage.py Tue Nov 26 18:03:23 2002
@@ -568,31 +568,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]
@@ -1089,6 +1064,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)