[Zodb-checkins] SVN: ZODB/branches/jim-storage-api-cleanup/src/Z Removed loadEx from storage API. It isn't needed. It is used

Jim Fulton jim at zope.com
Thu Apr 26 16:32:49 EDT 2007


Log message for revision 74816:
  Removed loadEx from storage API. It isn't needed.  It is used
  internally by ZEO, and then only as long as versions are barely
  supported, which isn't much longer.
  

Changed:
  U   ZODB/branches/jim-storage-api-cleanup/src/ZEO/ServerStub.py
  U   ZODB/branches/jim-storage-api-cleanup/src/ZEO/StorageServer.py
  U   ZODB/branches/jim-storage-api-cleanup/src/ZEO/interfaces.py
  U   ZODB/branches/jim-storage-api-cleanup/src/ZODB/DemoStorage.py
  U   ZODB/branches/jim-storage-api-cleanup/src/ZODB/FileStorage/FileStorage.py
  U   ZODB/branches/jim-storage-api-cleanup/src/ZODB/MappingStorage.py
  U   ZODB/branches/jim-storage-api-cleanup/src/ZODB/tests/IteratorStorage.py
  U   ZODB/branches/jim-storage-api-cleanup/src/ZODB/tests/RevisionStorage.py
  U   ZODB/branches/jim-storage-api-cleanup/src/ZODB/tests/TransactionalUndoVersionStorage.py
  U   ZODB/branches/jim-storage-api-cleanup/src/ZODB/tests/VersionStorage.py
  U   ZODB/branches/jim-storage-api-cleanup/src/ZODB/tests/test_storage.py

-=-
Modified: ZODB/branches/jim-storage-api-cleanup/src/ZEO/ServerStub.py
===================================================================
--- ZODB/branches/jim-storage-api-cleanup/src/ZEO/ServerStub.py	2007-04-26 20:32:46 UTC (rev 74815)
+++ ZODB/branches/jim-storage-api-cleanup/src/ZEO/ServerStub.py	2007-04-26 20:32:48 UTC (rev 74816)
@@ -177,13 +177,12 @@
         return self.rpc.call('zeoLoad', oid)
 
     ##
-    # Return current data for oid in version, the tid of the transaction that
-    # wrote the most recent revision, and the name of the version for the
-    # data returned.  Versions make this hard to understand; in particular,
-    # the version string returned may not equal the version string passed
-    # in, and that's "a feature" I don't understand.  Similarly, the tid
-    # returned is the tid of the most recent revision of oid, and that may
-    # not equal the tid of the transaction that wrote the data returned.
+    
+    # Return current data for oid in version, the tid of the
+    # transaction that wrote the most recent revision, and the name of
+    # the version for the data returned.  Note that if the object
+    # wasn't modified in the version, then the non-version data is
+    # returned and the returned version is an empty string.
     # @param oid object id
     # @param version string, name of version
     # @defreturn 3-tuple

Modified: ZODB/branches/jim-storage-api-cleanup/src/ZEO/StorageServer.py
===================================================================
--- ZODB/branches/jim-storage-api-cleanup/src/ZEO/StorageServer.py	2007-04-26 20:32:46 UTC (rev 74815)
+++ ZODB/branches/jim-storage-api-cleanup/src/ZEO/StorageServer.py	2007-04-26 20:32:48 UTC (rev 74816)
@@ -289,8 +289,15 @@
 
     def loadEx(self, oid, version):
         self.stats.loads += 1
-        return self.storage.loadEx(oid, version)
+        if version:
+            oversion = self.storage.modifiedInVersion(oid)
+            if oversion == version:
+                data, serial = self.storage.load(oid, version)
+                return data, serial, version
 
+        data, serial = self.storage.load(oid, '')
+        return data, serial, ''
+
     def loadBefore(self, oid, tid):
         self.stats.loads += 1
         return self.storage.loadBefore(oid, tid)

Modified: ZODB/branches/jim-storage-api-cleanup/src/ZEO/interfaces.py
===================================================================
--- ZODB/branches/jim-storage-api-cleanup/src/ZEO/interfaces.py	2007-04-26 20:32:46 UTC (rev 74815)
+++ ZODB/branches/jim-storage-api-cleanup/src/ZEO/interfaces.py	2007-04-26 20:32:48 UTC (rev 74816)
@@ -33,25 +33,6 @@
         return the transaction (object) being committed.  Otherwise
         return None.
         """
-
-    def loadEx(oid, version):
-        """Load current object data for a version
-
-        Return the current data, serial (transaction id) and version
-        for an object in a version.
-
-        If an object has been modified in the given version, then the
-        data and serial are for the most current revision of the
-        object and the returned version will match the given version.
-
-        If an object hasn't been modified in a version, or has been
-        modified in a version other than the given one, then the data,
-        and serial for the most recent non-version revision will be
-        returned along with an empty version string.
-
-        If a storage doesn't support versions, it should ignore the
-        version argument.
-        """
         
     def lastInvalidations(size):
         """Get recent transaction invalidations

Modified: ZODB/branches/jim-storage-api-cleanup/src/ZODB/DemoStorage.py
===================================================================
--- ZODB/branches/jim-storage-api-cleanup/src/ZODB/DemoStorage.py	2007-04-26 20:32:46 UTC (rev 74815)
+++ ZODB/branches/jim-storage-api-cleanup/src/ZODB/DemoStorage.py	2007-04-26 20:32:48 UTC (rev 74816)
@@ -218,37 +218,32 @@
         finally:
             self._lock_release()
 
-    def loadEx(self, oid, version):
+    def load(self, oid, version):
         self._lock_acquire()
         try:
             try:
                 oid, pre, vdata, p, tid = self._index[oid]
             except KeyError:
                 if self._base:
-                    return self._base.loadEx(oid, '')
+                    return self._base.load(oid, '')
                 raise KeyError(oid)
 
-            ver = ""
             if vdata:
                 oversion, nv = vdata
                 if oversion != version:
                     if nv:
                         # Return the current txn's tid with the non-version
                         # data.
-                        oid, pre, vdata, p, skiptid = nv
+                        p = nv[3]
                     else:
                         raise KeyError(oid)
-                ver = oversion
 
             if p is None:
                 raise KeyError(oid)
 
-            return p, tid, ver
+            return p, tid
         finally: self._lock_release()
 
-    def load(self, oid, version):
-        return self.loadEx(oid, version)[:2]
-
     def modifiedInVersion(self, oid):
         self._lock_acquire()
         try:

Modified: ZODB/branches/jim-storage-api-cleanup/src/ZODB/FileStorage/FileStorage.py
===================================================================
--- ZODB/branches/jim-storage-api-cleanup/src/ZODB/FileStorage/FileStorage.py	2007-04-26 20:32:46 UTC (rev 74815)
+++ ZODB/branches/jim-storage-api-cleanup/src/ZODB/FileStorage/FileStorage.py	2007-04-26 20:32:48 UTC (rev 74816)
@@ -515,32 +515,6 @@
         except TypeError:
             raise TypeError("invalid oid %r" % (oid,))
 
-    def loadEx(self, oid, version):
-        # A variant of load() that also returns the version string.
-        # ZEO wants this for managing its cache.
-        self._lock_acquire()
-        try:
-            pos = self._lookup_pos(oid)
-            h = self._read_data_header(pos, oid)
-            if h.version and h.version != version:
-                # Return data and tid from pnv (non-version data).
-                # If we return the old record's transaction id, then
-                # it will look to the cache like old data is current.
-                # The tid for the current data must always be greater
-                # than any non-current data.
-                data = self._loadBack_impl(oid, h.pnv)[0]
-                return data, h.tid, ""
-            if h.plen:
-                data = self._file.read(h.plen)
-                return data, h.tid, h.version
-            else:
-                # Get the data from the backpointer, but tid from
-                # currnt txn.
-                data = self._loadBack_impl(oid, h.back)[0]
-                return data, h.tid, h.version
-        finally:
-            self._lock_release()
-
     def load(self, oid, version):
         """Return pickle data and serial number."""
         self._lock_acquire()

Modified: ZODB/branches/jim-storage-api-cleanup/src/ZODB/MappingStorage.py
===================================================================
--- ZODB/branches/jim-storage-api-cleanup/src/ZODB/MappingStorage.py	2007-04-26 20:32:46 UTC (rev 74815)
+++ ZODB/branches/jim-storage-api-cleanup/src/ZODB/MappingStorage.py	2007-04-26 20:32:48 UTC (rev 74816)
@@ -63,11 +63,6 @@
         finally:
             self._lock_release()
 
-    def loadEx(self, oid, version):
-        # Since we don't support versions, just tack the empty version
-        # string onto load's result.
-        return self.load(oid, version) + ("",)
-
     def getTid(self, oid):
         self._lock_acquire()
         try:

Modified: ZODB/branches/jim-storage-api-cleanup/src/ZODB/tests/IteratorStorage.py
===================================================================
--- ZODB/branches/jim-storage-api-cleanup/src/ZODB/tests/IteratorStorage.py	2007-04-26 20:32:46 UTC (rev 74815)
+++ ZODB/branches/jim-storage-api-cleanup/src/ZODB/tests/IteratorStorage.py	2007-04-26 20:32:48 UTC (rev 74816)
@@ -144,21 +144,7 @@
         finally:
             self._storage.tpc_finish(t)
 
-    def checkLoadEx(self):
-        oid = self._storage.new_oid()
-        self._dostore(oid, data=42)
-        data, tid, ver = self._storage.loadEx(oid, "")
-        self.assertEqual(zodb_unpickle(data), MinPO(42))
-        match = False
-        for txn in self._storage.iterator():
-            for rec in txn:
-                if rec.oid == oid and rec.tid == tid:
-                    self.assertEqual(txn.tid, tid)
-                    match = True
-        if not match:
-            self.fail("Could not find transaction with matching id")
 
-
 class ExtendedIteratorStorage(IteratorCompare):
 
     def checkExtendedIteration(self):

Modified: ZODB/branches/jim-storage-api-cleanup/src/ZODB/tests/RevisionStorage.py
===================================================================
--- ZODB/branches/jim-storage-api-cleanup/src/ZODB/tests/RevisionStorage.py	2007-04-26 20:32:46 UTC (rev 74815)
+++ ZODB/branches/jim-storage-api-cleanup/src/ZODB/tests/RevisionStorage.py	2007-04-26 20:32:48 UTC (rev 74816)
@@ -52,7 +52,7 @@
             snooze()
             snooze()
             revid = self._dostore(oid, revid, data=MinPO(i))
-            revs.append(self._storage.loadEx(oid, ""))
+            revs.append(self._storage.load(oid, ""))
 
         prev = u64(revs[0][1])
         for i in range(1, 10):
@@ -123,10 +123,10 @@
             # Always undo the most recent txn, so the value will
             # alternate between 3 and 4.
             self._undo(tid, [oid], note="undo %d" % i)
-            revs.append(self._storage.loadEx(oid, ""))
+            revs.append(self._storage.load(oid, ""))
 
         prev_tid = None
-        for i, (data, tid, ver) in enumerate(revs):
+        for i, (data, tid) in enumerate(revs):
             t = self._storage.loadBefore(oid, p64(u64(tid) + 1))
             self.assertEqual(data, t[0])
             self.assertEqual(tid, t[1])

Modified: ZODB/branches/jim-storage-api-cleanup/src/ZODB/tests/TransactionalUndoVersionStorage.py
===================================================================
--- ZODB/branches/jim-storage-api-cleanup/src/ZODB/tests/TransactionalUndoVersionStorage.py	2007-04-26 20:32:46 UTC (rev 74815)
+++ ZODB/branches/jim-storage-api-cleanup/src/ZODB/tests/TransactionalUndoVersionStorage.py	2007-04-26 20:32:48 UTC (rev 74816)
@@ -22,6 +22,7 @@
 from ZODB.tests.MinPO import MinPO
 from ZODB.tests.StorageTestBase import zodb_unpickle
 
+from ZODB.tests.VersionStorage import loadEx
 
 class TransactionalUndoVersionStorage:
 
@@ -132,16 +133,15 @@
         self.assertEqual(load_value(oid1), 0)
         self.assertEqual(load_value(oid1, version), 2)
 
-        data, tid, ver = self._storage.loadEx(oid1, "")
+        data, tid = self._storage.load(oid1, "")
         # After undoing the version commit, the non-version data
         # once again becomes the non-version data from 'create1'.
         self.assertEqual(tid, self._storage.lastTransaction())
-        self.assertEqual(ver, "")
 
         # The current version data comes from an undo record, which
         # means that it gets data via the backpointer but tid from the
         # current txn.
-        data, tid, ver = self._storage.loadEx(oid1, version)
+        data, tid, ver = loadEx(self._storage, oid1, version)
         self.assertEqual(ver, version)
         self.assertEqual(tid, self._storage.lastTransaction())
 

Modified: ZODB/branches/jim-storage-api-cleanup/src/ZODB/tests/VersionStorage.py
===================================================================
--- ZODB/branches/jim-storage-api-cleanup/src/ZODB/tests/VersionStorage.py	2007-04-26 20:32:46 UTC (rev 74815)
+++ ZODB/branches/jim-storage-api-cleanup/src/ZODB/tests/VersionStorage.py	2007-04-26 20:32:48 UTC (rev 74816)
@@ -27,6 +27,16 @@
 from ZODB.tests.StorageTestBase import zodb_unpickle, snooze
 from ZODB import DB
 
+def loadEx(storage, oid, version):
+    v = storage.modifiedInVersion(oid)
+    if v == version:
+        data, serial = storage.load(oid, version)
+        return data, serial, version
+    else:
+        data, serial = storage.load(oid, '')
+        return data, serial, ''
+        
+
 class VersionStorage:
 
     def checkCommitVersionSerialno(self):
@@ -46,7 +56,7 @@
         revid1 = self._dostore(oid, data=MinPO(12))
         revid2 = self._dostore(oid, revid=revid1, data=MinPO(13),
                                version="version")
-        data, tid, ver = self._storage.loadEx(oid, "version")
+        data, tid, ver = loadEx(self._storage, oid, "version")
         self.assertEqual(revid2, tid)
         self.assertEqual(zodb_unpickle(data), MinPO(13))
         oids = self._abortVersion("version")
@@ -55,7 +65,7 @@
         # use repr() to avoid getting binary data in a traceback on error
         self.assertNotEqual(revid1, revid3)
         self.assertNotEqual(revid2, revid3)
-        data, tid, ver = self._storage.loadEx(oid, "")
+        data, tid = self._storage.load(oid, "")
         self.assertEqual(revid3, tid)
         self.assertEqual(zodb_unpickle(data), MinPO(12))
         self.assertEqual(tid, self._storage.lastTransaction())
@@ -83,10 +93,10 @@
         if hasattr(self._storage, 'getTid'):
             s = self._storage.getTid(oid)
             eq(s, max(revid, vrevid))
-        data, tid, ver = self._storage.loadEx(oid, version)
+        data, tid, ver = loadEx(self._storage, oid, version)
         eq(zodb_unpickle(data), MinPO(15))
         eq(tid, revid2)
-        data, tid, ver = self._storage.loadEx(oid, "other version")
+        data, tid, ver = loadEx(self._storage, oid, "other version")
         eq(zodb_unpickle(data), MinPO(12))
         eq(tid, revid2)
         # loadSerial returns non-version data
@@ -202,7 +212,7 @@
         # after a version is aborted.
         oid, version = self._setup_version()
         self._abortVersion(version)
-        data, tid, ver = self._storage.loadEx(oid, "")
+        data, tid, ver = loadEx(self._storage, oid, "")
         # write a new revision of oid so that the aborted-version txn
         # is not current
         self._dostore(oid, revid=tid, data=MinPO(17))

Modified: ZODB/branches/jim-storage-api-cleanup/src/ZODB/tests/test_storage.py
===================================================================
--- ZODB/branches/jim-storage-api-cleanup/src/ZODB/tests/test_storage.py	2007-04-26 20:32:46 UTC (rev 74815)
+++ ZODB/branches/jim-storage-api-cleanup/src/ZODB/tests/test_storage.py	2007-04-26 20:32:48 UTC (rev 74816)
@@ -74,19 +74,16 @@
     def _clear_temp(self):
         pass
 
-    def loadEx(self, oid, version):
+    def load(self, oid, version):
         self._lock_acquire()
         try:
             assert not version
             tid = self._cur[oid]
-            self.hook(oid, tid, version)
-            return self._index[(oid, tid)], tid, ""
+            self.hook(oid, tid, '')
+            return self._index[(oid, tid)], tid
         finally:
             self._lock_release()
 
-    def load(self, oid, version):
-        return self.loadEx(oid, version)[:2]
-
     def _begin(self, tid, u, d, e):
         self._txn = Transaction(tid)
 



More information about the Zodb-checkins mailing list