[Zodb-checkins] CVS: ZODB3/ZODB - DemoStorage.py:1.18

Jeremy Hylton jeremy at zope.com
Tue Apr 22 15:11:44 EDT 2003


Update of /cvs-repository/ZODB3/ZODB
In directory cvs.zope.org:/tmp/cvs-serv7718

Modified Files:
	DemoStorage.py 
Log Message:
Guard against not having a base in all cases.


=== ZODB3/ZODB/DemoStorage.py 1.17 => 1.18 ===
--- ZODB3/ZODB/DemoStorage.py:1.17	Mon Mar 17 13:24:57 2003
+++ ZODB3/ZODB/DemoStorage.py	Tue Apr 22 14:11:44 2003
@@ -90,7 +90,6 @@
 class DemoStorage(BaseStorage.BaseStorage):
 
     def __init__(self, name='Demo Storage', base=None, quota=None):
-
         BaseStorage.BaseStorage.__init__(self, name, base)
 
         # We use a BTree because the items are sorted!
@@ -226,13 +225,16 @@
 
         self._lock_acquire()
         try:
-            old=self._index.get(oid, None)
+            old = self._index.get(oid, None)
             if old is None:
                 # Hm, nothing here, check the base version:
-                try: p, oserial = self._base.load(oid, '')
-                except: pass
-                else:
-                    old= oid, oserial, None, None, p
+                if self._base:
+                    try:
+                        p, oserial = self._base.load(oid, '')
+                    except KeyError:
+                        pass
+                    else:
+                        old = oid, oserial, None, None, p
 
             nv=None
             if old:
@@ -453,9 +455,9 @@
                 # Scan non-version pickle for references
                 r=index.get(oid, None)
                 if r is None:
-                    # Base storage
-                    p, s = self._base.load(oid, '')
-                    referencesf(p, rootl)
+                    if self._base:
+                        p, s = self._base.load(oid, '')
+                        referencesf(p, rootl)
                 else:
                     pindex[oid]=r
                     oid, serial, pre, vdata, p = r




More information about the Zodb-checkins mailing list