[Zodb-checkins] CVS: StandaloneZODB/ZODB - DemoStorage.py:1.11

Jeremy Hylton jeremy@zope.com
Fri, 29 Mar 2002 17:29:13 -0500


Update of /cvs-repository/StandaloneZODB/ZODB
In directory cvs.zope.org:/tmp/cvs-serv25924

Modified Files:
	DemoStorage.py 
Log Message:
Simplify implementation of undoLog() and add comment about how it
appears to be broken.


=== StandaloneZODB/ZODB/DemoStorage.py 1.10 => 1.11 ===
 
     def undoLog(self, first, last, filter=None):
+        # I think this is wrong given the handling of first and last
+        # in FileStorage.
         self._lock_acquire()
         try:
-            transactions=self._data.items()
-            pos=len(transactions)
-            encode=base64.encodestring
-            r=[]
-            append=r.append
-            i=0
+            transactions = self._data.items()
+            pos = len(transactions)
+            r = []
+            i = 0
             while i < last and pos:
-                pos=pos-1
+                pos = pos - 1
                 if i < first:
-                    i = i+1
+                    i = i + 1
                     continue
                 tid, (p, u, d, e, t) = transactions[pos]
-                if p: continue
-                d={'id': encode(tid)[:-1],
-                   'time': TimeStamp(tid).timeTime(),
-                   'user_name': u, 'description': d}
+                if p:
+                    continue
+                d = {'id': base64.encodestring(tid)[:-1],
+                     'time': TimeStamp(tid).timeTime(),
+                     'user_name': u, 'description': d}
                 if e:
                     d.update(loads(e))
 
                 if filter is None or filter(d):
-                    append(d)
-                    i=i+1
-                
+                    r.append(d)
+                    i = i + 1
             return r
-        finally: self._lock_release()
+        finally:
+            self._lock_release()
 
     def versionEmpty(self, version):
         return not self._vindex.get(version, None)