[Zodb-checkins] CVS: Zope/lib/python/ZODB - BaseStorage.py:1.20.4.1 DemoStorage.py:1.12.4.1 FileStorage.py:1.95.4.1 POSException.py:1.12.4.2

Chris McDonough chrism@zope.com
Thu, 29 Aug 2002 01:31:55 -0400


Update of /cvs-repository/Zope/lib/python/ZODB
In directory cvs.zope.org:/tmp/cvs-serv30531/lib/python/ZODB

Modified Files:
      Tag: chrism-install-branch
	BaseStorage.py DemoStorage.py FileStorage.py POSException.py 
Log Message:
CVS up -j from HEAD on chrism-installer-branch.

Sorry folks on various mailing lists whom are subjected to this.
If I knew how to cut down on unnecessary checkin messages to
the lists, I would.



=== Zope/lib/python/ZODB/BaseStorage.py 1.20 => 1.20.4.1 ===
--- Zope/lib/python/ZODB/BaseStorage.py:1.20	Wed Aug 14 18:07:09 2002
+++ Zope/lib/python/ZODB/BaseStorage.py	Thu Aug 29 01:31:23 2002
@@ -75,6 +75,7 @@
         return ''
 
     def new_oid(self, last=None):
+        # 'last' is only for internal use, not part of the public API
         if self._is_read_only:
             raise POSException.ReadOnlyError()
         if last is None:


=== Zope/lib/python/ZODB/DemoStorage.py 1.12 => 1.12.4.1 ===
--- Zope/lib/python/ZODB/DemoStorage.py:1.12	Wed Aug 14 18:07:09 2002
+++ Zope/lib/python/ZODB/DemoStorage.py	Thu Aug 29 01:31:23 2002
@@ -134,20 +134,20 @@
 
         self._lock_acquire()
         try:
-            v=self._vindex.get(src, None)
-            if not v: return
+            v = self._vindex.get(src, None)
+            if not v:
+                return
 
-            tindex=self._tindex
-            oids=[]
+            oids = []
             for r in v.values():
                 oid, serial, pre, (version, nv), p = r
                 if nv:
                     oids.append(oid)
                     oid, serial, pre, vdata, p = nv
-                    tindex.append([oid, serial, r, None, p])
+                    self._tindex.append([oid, serial, r, None, p])
                 else:
                     # effectively, delete the thing
-                    tindex.append([oid, None, r, None, None])
+                    self._tindex.append([oid, None, r, None, None])
 
             return oids
 
@@ -168,6 +168,7 @@
             v=self._vindex.get(src, None)
             if v is None: return
 
+            newserial = self._serial
             tindex=self._tindex
             oids=[]
             for r in v.values():
@@ -178,7 +179,7 @@
                     new_vdata = dest, vdata[1]
                 else:
                     new_vdata = None
-                tindex.append([oid, serial, r, new_vdata, p])
+                tindex.append([oid, newserial, r, new_vdata, p])
 
 
             return oids
@@ -269,38 +270,38 @@
     def supportsVersions(self): return 1
 
     def _clear_temp(self):
-        self._tindex=[]
-        self._tsize=self._size+160
+        self._tindex = []
+        self._tsize = self._size + 160
 
     def _begin(self, tid, u, d, e):
-        self._tsize=self._size+120+len(u)+len(d)+len(e)
+        self._tsize = self._size + 120 + len(u) + len(d) + len(e)
 
     def _finish(self, tid, user, desc, ext):
+        self._size = self._tsize
 
-        index=self._index
-        tindex=self._tindex
-        vindex=self._vindex
-
-        self._size=self._tsize
-
-        self._data[tid]=None, user, desc, ext, tuple(tindex)
-        for r in tindex:
+        self._data[tid] = None, user, desc, ext, tuple(self._tindex)
+        for r in self._tindex:
             oid, serial, pre, vdata, p = r
-            old=index.get(oid, None)
+            old = self._index.get(oid)
+            # If the object had version data, remove the version data.
             if old is not None:
-                oldvdata=old[3]
+                oldvdata = old[3]
                 if oldvdata:
-                    v=vindex[oldvdata[0]]
+                    v = self._vindex[oldvdata[0]]
                     del v[oid]
-                    if not v: del vindex[oldvdata[0]]
+                    if not v:
+                        # If the version info is now empty, remove it.
+                        del self._vindex[oldvdata[0]]
 
-            index[oid]=r
+            self._index[oid] = r
 
+            # If there is version data, then udpate self._vindex, too.
             if vdata:
-                version=vdata[0]
-                v=vindex.get(version, None)
-                if v is None: v=vindex[version]={}
-                v[oid]=r
+                version = vdata[0]
+                v = self._vindex.get(version)
+                if v is None:
+                    v = self._vindex[version] = {}
+                v[oid] = r
 
     def undo(self, transaction_id):
         self._lock_acquire()


=== Zope/lib/python/ZODB/FileStorage.py 1.95 => 1.95.4.1 ===
--- Zope/lib/python/ZODB/FileStorage.py:1.95	Wed Aug 14 18:07:09 2002
+++ Zope/lib/python/ZODB/FileStorage.py	Thu Aug 29 01:31:23 2002
@@ -483,18 +483,30 @@
         current_oids = {}
         t = None
         tstatus = ' '
+        if abort is None:
+            newserial = self._serial
 
         while srcpos:
             self._file.seek(srcpos)
             h = self._file.read(DATA_VERSION_HDR_LEN)
             # h -> oid, serial, prev(oid), tloc, vlen, plen, pnv, pv
-            oid=h[:8]
-            pnv=h[-16:-8]
+            oid = h[:8]
+            pnv = h[-16:-8]
+            if abort:
+                # If we are aborting, the serialno in the new data
+                # record should be the same as the serialno in the last
+                # non-version data record.
+                # XXX This might be the only time that the serialno
+                # of a data record does not match the transaction id.
+                self._file.seek(U64(pnv))
+                h_pnv = self._file.read(DATA_VERSION_HDR_LEN)
+                newserial = h_pnv[8:16]
+            
             if self._index.get(oid) == srcpos:
                 # This is a current record!
                 self._tindex[oid] = here
                 oids.append(oid)
-                self._tfile.write(h[:16] + spos + middle)
+                self._tfile.write(oid + newserial + spos + middle)
                 if dest:
                     self._tvindex[dest] = here
                     self._tfile.write(pnv + sd + dest)
@@ -576,26 +588,27 @@
 
     def _load(self, oid, version, _index, file):
         try:
-            pos=_index[oid]
+            pos = _index[oid]
         except KeyError:
             raise POSKeyError(oid)
         file.seek(pos)
-        read=file.read
-        h=read(DATA_HDR_LEN)
-        doid,serial,prev,tloc,vlen,plen = unpack(">8s8s8s8sH8s", h)
-        if doid != oid: raise CorruptedDataError, h
+        read = file.read
+        h = read(DATA_HDR_LEN)
+        doid, serial, prev, tloc, vlen, plen = unpack(">8s8s8s8sH8s", h)
+        if doid != oid:
+            raise CorruptedDataError, h
         if vlen:
-            pnv=read(8) # Read location of non-version data
+            pnv = read(8) # Read location of non-version data
             if (not version or len(version) != vlen or
                 (read(8) # skip past version link
-                 and version != read(vlen))
-                ):
+                 and version != read(vlen))):
                 return _loadBack(file, oid, pnv)
 
         # If we get here, then either this was not a version record,
         # or we've already read past the version data!
-        if plen != z64: return read(U64(plen)), serial
-        pnv=read(8)
+        if plen != z64:
+            return read(U64(plen)), serial
+        pnv = read(8)
         # We use the current serial, since that is the one that
         # will get checked when we store.
         return _loadBack(file, oid, pnv)[0], serial
@@ -2097,9 +2110,6 @@
 
 
 def _loadBack(file, oid, back):
-##    seek=file.seek
-##    read=file.read
-
     while 1:
         old = U64(back)
         if not old:


=== Zope/lib/python/ZODB/POSException.py 1.12.4.1 => 1.12.4.2 ===
--- Zope/lib/python/ZODB/POSException.py:1.12.4.1	Mon Aug 26 02:22:38 2002
+++ Zope/lib/python/ZODB/POSException.py	Thu Aug 29 01:31:23 2002
@@ -14,6 +14,7 @@
 """BoboPOS-defined exceptions
 
 $Id$"""
+
 __version__ = '$Revision$'.split()[-2:][0]
 
 from string import join