Commit a0c8ed70 authored by Jeremy Hylton's avatar Jeremy Hylton

Guard against not having a base in all cases.

parent fb7d8993
...@@ -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:
else: p, oserial = self._base.load(oid, '')
old= oid, oserial, None, None, p except KeyError:
pass
else:
old = oid, oserial, None, None, p
nv=None nv=None
if old: if old:
...@@ -453,9 +455,9 @@ class DemoStorage(BaseStorage.BaseStorage): ...@@ -453,9 +455,9 @@ 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:
pindex[oid]=r pindex[oid]=r
oid, serial, pre, vdata, p = r oid, serial, pre, vdata, p = r
......
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