Commit 9279602d authored by Jim Fulton's avatar Jim Fulton

Got rid of some unnecessary imports.

Changed to use has_key rather than get to work with older mapping objects.

Added important note in constructor.
parent bf7db408
...@@ -158,9 +158,9 @@ method:: ...@@ -158,9 +158,9 @@ method::
and call it to minotor the storage. and call it to minotor the storage.
""" """
__version__='$Revision: 1.2 $'[11:-2] __version__='$Revision: 1.3 $'[11:-2]
import base64, POSException, BTree, BaseStorage, time, string, utils import POSException, BaseStorage, string, utils
from TimeStamp import TimeStamp from TimeStamp import TimeStamp
class MappingStorage(BaseStorage.BaseStorage): class MappingStorage(BaseStorage.BaseStorage):
...@@ -172,6 +172,11 @@ class MappingStorage(BaseStorage.BaseStorage): ...@@ -172,6 +172,11 @@ class MappingStorage(BaseStorage.BaseStorage):
self._index={} self._index={}
self._tindex=[] self._tindex=[]
# Note:
# If you subclass this and use a persistent mapping facility
# (e.g. a dbm file), you will need to get the maximum key and
# save it as self._oid. See dbmStorage.
def __len__(self): def __len__(self):
return len(self._index) return len(self._index)
...@@ -200,8 +205,8 @@ class MappingStorage(BaseStorage.BaseStorage): ...@@ -200,8 +205,8 @@ class MappingStorage(BaseStorage.BaseStorage):
self._lock_acquire() self._lock_acquire()
try: try:
old=self._index.get(oid, None) if self._index.has_key(oid):
if old is not None: old=self._index[oid]
oserial=old[:8] oserial=old[:8]
if serial != oserial: raise POSException.ConflictError if serial != oserial: raise POSException.ConflictError
......
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