[Zodb-checkins] CVS: ZODB3/BDBStorage - BDBFullStorage.py:1.44.4.6

Barry Warsaw barry at zope.com
Thu Jul 24 15:46:49 EDT 2003


Update of /cvs-repository/ZODB3/BDBStorage
In directory cvs.zope.org:/tmp/cvs-serv6898/BDBStorage

Modified Files:
      Tag: ZODB3-3_1-branch
	BDBFullStorage.py 
Log Message:
Back port a few changes from ZODB 3 head:

_doabort(): Protect from deleting non-existant pickles
  Only clean up the currentVersions tabl when vid <> ZERO
  Minor local variable naming consistency

getSerial(): Raise KeyError when the object has been uncreated.

_TransactionsIterator.iterator(): Add this, which just returns self,
meaning it can be used as the `other' arg to copyTransactionsFrom().


=== ZODB3/BDBStorage/BDBFullStorage.py 1.44.4.5 => 1.44.4.6 ===
--- ZODB3/BDBStorage/BDBFullStorage.py:1.44.4.5	Fri Jun 13 16:46:27 2003
+++ ZODB3/BDBStorage/BDBFullStorage.py	Thu Jul 24 14:46:42 2003
@@ -338,7 +338,10 @@
                 revid = oid+tid
                 vid = self._metadata[revid][:8]
                 self._metadata.delete(revid, txn=txn)
-                self._pickles.delete(revid, txn=txn)
+                try:
+                    self._pickles.delete(revid, txn=txn)
+                except db.DBNotFoundError:
+                    pass
                 # Clean up the object revisions table
                 try:
                     cr.set(oid+tid)
@@ -347,11 +350,8 @@
                 else:
                     cr.delete()
                 # Now we have to clean up the currentVersions table
-                try:
+                if vid <> ZERO:
                     cv.set_both(vid, revid)
-                except db.DBNotFoundError:
-                    pass
-                else:
                     cv.delete()
         finally:
             # There's a small window of opportunity for leaking cursors here,
@@ -362,17 +362,17 @@
             if cv: cv.close()
             if cr: cr.close()
         # Now clean up the vids and versions tables
-        cv = self._pvids.cursor(txn=txn)
+        cpv = self._pvids.cursor(txn=txn)
         try:
-            rec = cv.first()
+            rec = cpv.first()
             while rec:
                 vid = rec[0]
-                rec = cv.next()
+                rec = cpv.next()
                 version = self._versions[vid]
                 self._versions.delete(vid, txn=txn)
                 self._vids.delete(version, txn=txn)
         finally:
-            cv.close()
+            cpv.close()
         # Now clean up the tid indexed table, and the temporary log tables
         self._txnMetadata.delete(tid, txn=txn)
         self._oids.truncate(txn)
@@ -1053,6 +1053,10 @@
         self._lock_acquire()
         try:
             serial, tid = self._getSerialAndTid(oid)
+            # See if the object has been uncreated
+            lrevid = unpack('>8s', self._metadata[oid+tid][16:24])[0]
+            if lrevid == DNE:
+                raise KeyError
             return serial
         finally:
             self._lock_release()
@@ -1794,6 +1798,13 @@
         # This is a lie.  It's here only for Python 2.1 support for
         # list()-ifying these objects.
         return 0
+
+    # This allows us to pass an iterator as the `other' argument to
+    # copyTransactionsFrom() in BaseStorage.  The advantage here is that we
+    # can create the iterator manually, e.g. setting start and stop, and then
+    # just let copyTransactionsFrom() do its thing.
+    def iterator(self):
+        return self
 
     def next(self):
         """Return the ith item in the sequence of transaction data.




More information about the Zodb-checkins mailing list