Commit 7b1532bf authored by Jeremy Hylton's avatar Jeremy Hylton

Simplify implementation of undoLog() and add comment about how it

appears to be broken.
parent 065bfea5
...@@ -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.10 $'[11:-2] __version__='$Revision: 1.11 $'[11:-2]
import base64, time, string import base64, time, string
from ZODB import POSException, BaseStorage, utils from ZODB import POSException, BaseStorage, utils
...@@ -354,33 +354,34 @@ class DemoStorage(BaseStorage.BaseStorage): ...@@ -354,33 +354,34 @@ class DemoStorage(BaseStorage.BaseStorage):
finally: self._lock_release() finally: self._lock_release()
def undoLog(self, first, last, filter=None): def undoLog(self, first, last, filter=None):
# I think this is wrong given the handling of first and last
# in FileStorage.
self._lock_acquire() self._lock_acquire()
try: try:
transactions=self._data.items() transactions = self._data.items()
pos=len(transactions) pos = len(transactions)
encode=base64.encodestring r = []
r=[] i = 0
append=r.append
i=0
while i < last and pos: while i < last and pos:
pos=pos-1 pos = pos - 1
if i < first: if i < first:
i = i+1 i = i + 1
continue continue
tid, (p, u, d, e, t) = transactions[pos] tid, (p, u, d, e, t) = transactions[pos]
if p: continue if p:
d={'id': encode(tid)[:-1], continue
'time': TimeStamp(tid).timeTime(), d = {'id': base64.encodestring(tid)[:-1],
'user_name': u, 'description': d} 'time': TimeStamp(tid).timeTime(),
'user_name': u, 'description': d}
if e: if e:
d.update(loads(e)) d.update(loads(e))
if filter is None or filter(d): if filter is None or filter(d):
append(d) r.append(d)
i=i+1 i = i + 1
return r return r
finally: self._lock_release() finally:
self._lock_release()
def versionEmpty(self, version): def versionEmpty(self, version):
return not self._vindex.get(version, None) return not self._vindex.get(version, None)
......
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