[Zodb-checkins] SVN: ZODB/trunk/src/ZODB/DemoStorage.py Changed to work with base storages that don't support versions.

Jim Fulton jim at zope.com
Thu Apr 26 19:19:26 EDT 2007


Log message for revision 74829:
  Changed to work with base storages that don't support versions.
  
  Removed unneeded loadEx.
  
  Added missing close method.
  

Changed:
  U   ZODB/trunk/src/ZODB/DemoStorage.py

-=-
Modified: ZODB/trunk/src/ZODB/DemoStorage.py
===================================================================
--- ZODB/trunk/src/ZODB/DemoStorage.py	2007-04-26 23:19:23 UTC (rev 74828)
+++ ZODB/trunk/src/ZODB/DemoStorage.py	2007-04-26 23:19:25 UTC (rev 74829)
@@ -117,10 +117,16 @@
         self._quota = quota
         self._ltid = None
         self._clear_temp()
-        if base is not None and base.versions():
-            raise POSException.StorageError(
-                "Demo base storage has version data")
 
+        try:
+            versions = base.versions
+        except AttributeError:
+            pass
+        else:
+            if base.versions():
+                raise POSException.StorageError(
+                    "Demo base storage has version data")
+
     # When DemoStorage needs to create a new oid, and there is a base
     # storage, it must use that storage's new_oid() method.  Else
     # DemoStorage may end up assigning "new" oids that are already in use
@@ -212,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, version)
+                    return self._base.load(oid, version)
                 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:
@@ -564,3 +565,7 @@
     def cleanup(self):
         if self._base is not None:
             self._base.cleanup()
+
+    def close(self):
+        if self._base is not None:
+            self._base.close()



More information about the Zodb-checkins mailing list