[Zodb-checkins] CVS: ZODB3/ZODB - FileStorage.py:1.114 __init__.py:1.20
Jeremy Hylton
jeremy@zope.com
Tue, 5 Nov 2002 16:49:50 -0500
Update of /cvs-repository/ZODB3/ZODB
In directory cvs.zope.org:/tmp/cvs-serv15043
Modified Files:
FileStorage.py __init__.py
Log Message:
Various small cleanups, mostly from pychecker.
Remove useless register_subsystem() calls.
Define PackError instead of raising string exception.
Remove unused _stuff argument from load().
Remove unused tid argument from _txn_undo_write().
Replace seek() and unused read()s with single read().
Remove unused local variables.
=== ZODB3/ZODB/FileStorage.py 1.113 => 1.114 ===
--- ZODB3/ZODB/FileStorage.py:1.113 Tue Nov 5 16:37:57 2002
+++ ZODB3/ZODB/FileStorage.py Tue Nov 5 16:49:50 2002
@@ -145,7 +145,6 @@
return {}
from zLOG import LOG, BLATHER, WARNING, ERROR, PANIC, register_subsystem
-register_subsystem('ZODB FS')
z64='\0'*8
# the struct formats for the headers
@@ -176,7 +175,11 @@
LOG('ZODB FS', PANIC, "%s ERROR: %s\n" % (packed_version, message))
raise CorruptedTransactionError, message
-class FileStorageError(POSException.StorageError): pass
+class FileStorageError(POSException.StorageError):
+ pass
+
+class PackError(FileStorageError):
+ pass
class FileStorageFormatError(FileStorageError):
"""Invalid file format
@@ -617,7 +620,7 @@
# will get checked when we store.
return _loadBack(file, oid, pnv)[0], serial
- def load(self, oid, version, _stuff=None):
+ def load(self, oid, version):
self._lock_acquire()
try:
return self._load(oid, version, self._index, self._file)
@@ -1135,7 +1138,7 @@
tid = base64.decodestring(transaction_id + '\n')
assert len(tid) == 8
tpos = self._txn_find(tid)
- tindex = self._txn_undo_write(tpos, tid)
+ tindex = self._txn_undo_write(tpos)
self._tindex.update(tindex)
return tindex.keys()
@@ -1155,7 +1158,7 @@
break
raise UndoError("Invalid transaction id")
- def _txn_undo_write(self, tpos, tid):
+ def _txn_undo_write(self, tpos):
# a helper function to write the data records for transactional undo
ostloc = p64(self._pos)
@@ -1295,8 +1298,7 @@
prev=U64(prev)
if vlen:
- nv = read(8) != z64
- file.seek(8,1) # Skip previous version record pointer
+ read(16)
version=read(vlen)
if wantver is not None and version != wantver:
if prev:
@@ -1412,8 +1414,6 @@
pindex[oid]=0
error('Bad reference to %s', `(oid,v)`)
- spackpos=p64(packpos)
-
##################################################################
# Step 2, copy data and compute new index based on new positions.
index, vindex, tindex, tvindex = self._newIndexes()
@@ -1506,7 +1506,7 @@
thl=ul+dl+el
h=read(thl)
if len(h) != thl:
- raise 'Pack Error', opos
+ raise PackError(opos)
write(h)
thl=TRANS_HDR_LEN+thl
pos=tpos+thl
@@ -1771,7 +1771,6 @@
p1=opos
p2=pos
offset=p2-p1
- packpos=opos
# Copy the data in two stages. In the packing stage,
# we skip records that are non-current or that are for
@@ -1798,7 +1797,8 @@
thl=ul+dl+el
h2=read(thl)
- if len(h2) != thl: raise 'Pack Error', opos
+ if len(h2) != thl:
+ raise PackError(opos)
# write out the transaction record
seek(opos)
@@ -1950,11 +1950,9 @@
return 4L, maxoid, ltid
index_get=index.get
- vndexpos=vindex.get
pos=start
seek(start)
- unpack=struct.unpack
tid='\0'*7+'\1'
while 1:
@@ -2045,13 +2043,8 @@
if vlen:
dlen=dlen+(16+vlen)
- seek(8,1)
- pv=U64(read(8))
+ read(16)
version=read(vlen)
- # Jim says: "It's just not worth the bother."
- #if vndexpos(version, 0) != pv:
- # panic("%s incorrect previous version pointer at %s",
- # name, pos)
vindex[version]=pos
if pos+dlen > tend or tloc != tpos:
@@ -2341,15 +2334,13 @@
self._file.seek(pos)
h = self._file.read(DATA_HDR_LEN)
oid, serial, sprev, stloc, vlen, splen = unpack(DATA_HDR, h)
- prev = U64(sprev)
tloc = U64(stloc)
plen = U64(splen)
dlen = DATA_HDR_LEN + (plen or 8)
if vlen:
dlen += (16 + vlen)
- tmp = self._file.read(16)
- pv = U64(tmp[8:16])
+ self._file.read(16) # move to the right location
version = self._file.read(vlen)
else:
version = ''
=== ZODB3/ZODB/__init__.py 1.19 => 1.20 ===
--- ZODB3/ZODB/__init__.py:1.19 Wed Oct 30 13:58:29 2002
+++ ZODB3/ZODB/__init__.py Tue Nov 5 16:49:50 2002
@@ -17,7 +17,6 @@
import sys
import cPersistence, Persistence
from zLOG import register_subsystem
-register_subsystem('ZODB')
# This is lame. Don't look. :(
sys.modules['cPersistence'] = cPersistence