[Zodb-checkins] CVS: ZODB4/src/zodb/storage - base.py:1.13.4.2

Barry Warsaw barry@wooz.org
Mon, 10 Mar 2003 14:33:24 -0500


Update of /cvs-repository/ZODB4/src/zodb/storage
In directory cvs.zope.org:/tmp/cvs-serv14123

Modified Files:
      Tag: opaque-pickles-branch
	base.py 
Log Message:
copyTransactionsFrom(): Storage method .restore() now takes an extra
refs argument.

splitrefs(): Convenience function.

_splitoids(): Removed.

_update(): Use splitrefs() instead of _splitoids()


=== ZODB4/src/zodb/storage/base.py 1.13.4.1 => 1.13.4.2 ===
--- ZODB4/src/zodb/storage/base.py:1.13.4.1	Mon Feb 10 17:58:52 2003
+++ ZODB4/src/zodb/storage/base.py	Mon Mar 10 14:33:23 2003
@@ -1,4 +1,3 @@
-
 ##############################################################################
 #
 # Copyright (c) 2001 Zope Corporation and Contributors.
@@ -337,10 +336,20 @@
                 if verbose:
                     print `r.oid`, r.version, len(r.data)
                 self.restore(r.oid, r.serial, r.data, r.version,
-                             r.data_txn, transaction)
+                             r.data_txn, r.refs, transaction)
             self.tpcVote(transaction)
             self.tpcFinish(transaction)
 
+# A couple of convenience methods
+def splitrefs(refstr, oidlen=8):
+    if not refstr:
+        return []
+    num, extra = divmod(len(refstr), oidlen)
+    fmt = '%ds' % oidlen
+    assert extra == 0, refstr
+    return struct.unpack('>' + (fmt * num), refstr)
+
+
 
 class BerkeleyConfig:
     """Bag of attributes for configuring Berkeley based storages.
@@ -699,13 +708,8 @@
         os.unlink(lockfile)
 
     # A couple of convenience methods
-    def _splitoids(self, referents):
-        num, extra = divmod(len(referents), 8)
-        assert extra == 0, referents
-        return struct.unpack('>' + ('8s' * num), referents)
-
     def _update(self, deltas, referents, incdec):
-        for oid in self._splitoids(referents):
+        for oid in splitrefs(referents):
             rc = deltas.get(oid, 0) + incdec
             if rc == 0:
                 # Save space in the dict by zapping zeroes