[Zodb-checkins] SVN: ZODB/branches/gocept-iteration/src/ZODB/DemoStorage.py - Clean up demostorage so it doesn't create empty transactions. None of the

Christian Theune ct at gocept.com
Thu Feb 14 09:07:44 EST 2008


Log message for revision 83834:
  - Clean up demostorage so it doesn't create empty transactions. None of the
    other storages create empty transactions either.
  - Unpickle the transaction info`s extension data.
  

Changed:
  U   ZODB/branches/gocept-iteration/src/ZODB/DemoStorage.py

-=-
Modified: ZODB/branches/gocept-iteration/src/ZODB/DemoStorage.py
===================================================================
--- ZODB/branches/gocept-iteration/src/ZODB/DemoStorage.py	2008-02-14 14:06:28 UTC (rev 83833)
+++ ZODB/branches/gocept-iteration/src/ZODB/DemoStorage.py	2008-02-14 14:07:42 UTC (rev 83834)
@@ -80,14 +80,16 @@
 
 """
 
+import cPickle
 import base64, time
+
 import ZODB.BaseStorage
 from ZODB import POSException
 from ZODB.utils import z64, oid_repr
 from persistent.TimeStamp import TimeStamp
-from cPickle import loads
 from BTrees import OOBTree
 
+
 class DemoStorage(ZODB.BaseStorage.BaseStorage):
     """Demo storage
 
@@ -317,6 +319,10 @@
         self._tsize = self._size + 120 + len(u) + len(d) + len(e)
 
     def _finish(self, tid, user, desc, ext):
+        if not self._tindex:
+            # No data, so we don't update anything.
+            return
+
         self._size = self._tsize
 
         self._data[tid] = None, user, desc, ext, tuple(self._tindex)
@@ -364,7 +370,7 @@
                      'time': TimeStamp(tid).timeTime(),
                      'user_name': u, 'description': d}
                 if e:
-                    d.update(loads(e))
+                    d.update(cPickle.loads(e))
                 if filter is None or filter(d):
                     if i >= first:
                         r.append(d)
@@ -575,12 +581,13 @@
                 in self._data.items():
             if tid < start:
                 continue
-            if tid > stop:
+            if stop is not None and tid > stop:
                 break
             if packed:
                 status = 'p'
             else:
                 status = ' '
+            extension = cPickle.loads(extension)
             yield TransactionRecord(
                 tid, status, user, description, extension, records)
 



More information about the Zodb-checkins mailing list