Commit 07766aca authored by Jeremy Hylton's avatar Jeremy Hylton

Guard against not having a base in all cases.

parent 7f38c7b1
...@@ -79,7 +79,7 @@ method:: ...@@ -79,7 +79,7 @@ method::
and call it to monitor the storage. and call it to monitor the storage.
""" """
__version__='$Revision: 1.17 $'[11:-2] __version__='$Revision: 1.18 $'[11:-2]
import base64, time, string import base64, time, string
from ZODB import POSException, BaseStorage, utils from ZODB import POSException, BaseStorage, utils
...@@ -90,7 +90,6 @@ from BTrees import OOBTree ...@@ -90,7 +90,6 @@ from BTrees import OOBTree
class DemoStorage(BaseStorage.BaseStorage): class DemoStorage(BaseStorage.BaseStorage):
def __init__(self, name='Demo Storage', base=None, quota=None): def __init__(self, name='Demo Storage', base=None, quota=None):
BaseStorage.BaseStorage.__init__(self, name, base) BaseStorage.BaseStorage.__init__(self, name, base)
# We use a BTree because the items are sorted! # We use a BTree because the items are sorted!
...@@ -226,13 +225,16 @@ class DemoStorage(BaseStorage.BaseStorage): ...@@ -226,13 +225,16 @@ class DemoStorage(BaseStorage.BaseStorage):
self._lock_acquire() self._lock_acquire()
try: try:
old=self._index.get(oid, None) old = self._index.get(oid, None)
if old is None: if old is None:
# Hm, nothing here, check the base version: # Hm, nothing here, check the base version:
try: p, oserial = self._base.load(oid, '') if self._base:
except: pass try:
p, oserial = self._base.load(oid, '')
except KeyError:
pass
else: else:
old= oid, oserial, None, None, p old = oid, oserial, None, None, p
nv=None nv=None
if old: if old:
...@@ -453,7 +455,7 @@ class DemoStorage(BaseStorage.BaseStorage): ...@@ -453,7 +455,7 @@ class DemoStorage(BaseStorage.BaseStorage):
# Scan non-version pickle for references # Scan non-version pickle for references
r=index.get(oid, None) r=index.get(oid, None)
if r is None: if r is None:
# Base storage if self._base:
p, s = self._base.load(oid, '') p, s = self._base.load(oid, '')
referencesf(p, rootl) referencesf(p, rootl)
else: else:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment