Commit 7ceb5bd6 authored by Jim Fulton's avatar Jim Fulton

Changed to work with base storages that don't support versions.

Removed unneeded loadEx.

Added missing close method.
parent 1f21bc9c
...@@ -117,9 +117,15 @@ class DemoStorage(BaseStorage): ...@@ -117,9 +117,15 @@ class DemoStorage(BaseStorage):
self._quota = quota self._quota = quota
self._ltid = None self._ltid = None
self._clear_temp() self._clear_temp()
if base is not None and base.versions():
raise POSException.StorageError( try:
"Demo base storage has version data") 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 # When DemoStorage needs to create a new oid, and there is a base
# storage, it must use that storage's new_oid() method. Else # storage, it must use that storage's new_oid() method. Else
...@@ -212,37 +218,32 @@ class DemoStorage(BaseStorage): ...@@ -212,37 +218,32 @@ class DemoStorage(BaseStorage):
finally: finally:
self._lock_release() self._lock_release()
def loadEx(self, oid, version): def load(self, oid, version):
self._lock_acquire() self._lock_acquire()
try: try:
try: try:
oid, pre, vdata, p, tid = self._index[oid] oid, pre, vdata, p, tid = self._index[oid]
except KeyError: except KeyError:
if self._base: if self._base:
return self._base.loadEx(oid, version) return self._base.load(oid, version)
raise KeyError(oid) raise KeyError(oid)
ver = ""
if vdata: if vdata:
oversion, nv = vdata oversion, nv = vdata
if oversion != version: if oversion != version:
if nv: if nv:
# Return the current txn's tid with the non-version # Return the current txn's tid with the non-version
# data. # data.
oid, pre, vdata, p, skiptid = nv p = nv[3]
else: else:
raise KeyError(oid) raise KeyError(oid)
ver = oversion
if p is None: if p is None:
raise KeyError(oid) raise KeyError(oid)
return p, tid, ver return p, tid
finally: self._lock_release() finally: self._lock_release()
def load(self, oid, version):
return self.loadEx(oid, version)[:2]
def modifiedInVersion(self, oid): def modifiedInVersion(self, oid):
self._lock_acquire() self._lock_acquire()
try: try:
...@@ -564,3 +565,7 @@ class DemoStorage(BaseStorage): ...@@ -564,3 +565,7 @@ class DemoStorage(BaseStorage):
def cleanup(self): def cleanup(self):
if self._base is not None: if self._base is not None:
self._base.cleanup() self._base.cleanup()
def close(self):
if self._base is not None:
self._base.close()
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