[Zodb-checkins] CVS: ZODB3/ZODB - TmpStore.py:1.7.8.1 Transaction.py:1.39.2.2

Shane Hathaway shane@zope.com
Thu, 2 Jan 2003 13:05:10 -0500


Update of /cvs-repository/ZODB3/ZODB
In directory cvs.zope.org:/tmp/cvs-serv25870

Modified Files:
      Tag: ZODB3-3_1-branch
	TmpStore.py Transaction.py 
Log Message:
Corrected code that assumed OIDs are always 8 bytes long.  It's OK
that OIDs are required to be strings, but AdaptableStorage permits any
length, and so might other storages.


=== ZODB3/ZODB/TmpStore.py 1.7 => 1.7.8.1 ===
--- ZODB3/ZODB/TmpStore.py:1.7	Wed Aug 14 18:07:09 2002
+++ ZODB3/ZODB/TmpStore.py	Thu Jan  2 13:05:06 2003
@@ -25,7 +25,7 @@
 
         self._file=file
         self._index={}
-        self._pos=self._tpos=0
+        self._pos=self._tpos=0L
         self._bver=base_version
         self._tindex=[]
         self._db=None
@@ -49,10 +49,15 @@
             return self._storage.load(oid, self._bver)
         file=self._file
         file.seek(pos)
-        h=file.read(24)
-        if h[:8] != oid:
-            raise POSException.StorageSystemError, 'Bad temporary storage'
-        return file.read(u64(h[16:])), h[8:16]
+        h = self._file.read(8)
+        oidlen = u64(h)
+        read_oid = file.read(oidlen)
+        if read_oid != oid:
+            raise POSException.StorageSystemError('Bad temporary storage')
+        h = file.read(16)
+        size = u64(h[8:])
+        serial = h[:8]
+        return file.read(size), serial
 
     def modifiedInVersion(self, oid):
         if self._index.has_key(oid): return 1
@@ -73,10 +78,11 @@
         l=len(data)
         if serial is None:
             serial = '\0\0\0\0\0\0\0\0'
-        file.write(oid+serial+p64(l))
+        header = p64(len(oid)) + oid + serial + p64(l)
+        file.write(header)
         file.write(data)
         self._tindex.append((oid,pos))
-        self._pos=pos+l+24
+        self._pos += l + len(header)
         return serial
 
     def tpc_abort(self, transaction):


=== ZODB3/ZODB/Transaction.py 1.39.2.1 => 1.39.2.2 ===
--- ZODB3/ZODB/Transaction.py:1.39.2.1	Tue Nov 12 15:18:09 2002
+++ ZODB3/ZODB/Transaction.py	Thu Jan  2 13:05:06 2003
@@ -21,7 +21,6 @@
 from string import split, strip, join
 from zLOG import LOG, ERROR, PANIC, INFO, BLATHER, WARNING
 from POSException import ConflictError
-from ZODB import utils
 
 # Flag indicating whether certain errors have occurred.
 hosed=0
@@ -139,8 +138,8 @@
                     if t is None:
                         t, v, tb = sys.exc_info()
                     else:
-                        self.log("Failed to abort object %016x" %
-                                 utils.U64(o._p_oid), error=sys.exc_info())
+                        self.log("Failed to abort object %s" %
+                                 repr(o._p_oid), error=sys.exc_info())
 
             # tpc_begin() was never called, so tpc_abort() should not be
             # called.
@@ -392,7 +391,7 @@
                     j.abort(o, self)
             except:
                 # nothing to do but log the error
-                self.log("Failed to abort object %016x" % utils.U64(o._p_oid),
+                self.log("Failed to abort object %s" % repr(o._p_oid),
                          error=sys.exc_info())
 
         # Abort the two-phase commit.  It's only necessary to abort the