[Zodb-checkins] CVS: StandaloneZODB/ZODB - FileStorage.py:1.77.4.2 POSException.py:1.9.4.1
Jeremy Hylton
jeremy@zope.com
Wed, 23 Jan 2002 18:10:04 -0500
Update of /cvs-repository/StandaloneZODB/ZODB
In directory cvs.zope.org:/tmp/cvs-serv1602
Modified Files:
Tag: Recovery
FileStorage.py POSException.py
Log Message:
Add POSKeyError, which has a nicer str() than regular KeyError.
=== StandaloneZODB/ZODB/FileStorage.py 1.77.4.1 => 1.77.4.2 ===
from struct import pack, unpack
import POSException
-from POSException import UndoError
+from POSException import UndoError, POSKeyError
from TimeStamp import TimeStamp
from lock_file import lock_file
from utils import t32, p64, U64, cp
@@ -574,7 +574,10 @@
file=self._file
seek=file.seek
read=file.read
- pos=_index[oid]
+ try:
+ pos=_index[oid]
+ except KeyError:
+ raise POSKeyError(oid)
while 1:
seek(pos)
h=read(42)
@@ -583,7 +586,8 @@
if dserial == serial: break # Yeee ha!
# Keep looking for serial
pos=U64(prev)
- if not pos: raise KeyError, serial
+ if not pos:
+ raise POSKeyError(serial)
continue
if vlen:
@@ -2006,7 +2010,8 @@
while 1:
old=U64(back)
- if not old: raise KeyError, oid
+ if not old:
+ raise POSKeyError(oid)
seek(old)
h=read(42)
doid,serial,prev,tloc,vlen,plen = unpack(">8s8s8s8sH8s", h)
@@ -2023,7 +2028,8 @@
while 1:
old=U64(back)
- if not old: raise KeyError, oid
+ if not old:
+ raise POSKeyError(oid)
seek(old)
h=read(42)
doid,serial,prev,tloc,vlen,plen = unpack(">8s8s8s8sH8s", h)
=== StandaloneZODB/ZODB/POSException.py 1.9 => 1.9.4.1 ===
"""
+class POSKeyError(KeyError, POSError):
+ """Key not found in database
+ """
+
+ def __str__(self):
+ return "%016x" % utils.U64(self.args[0])
+
class TransactionError(POSError):
"""An error occured due to normal transaction processing
"""