[Checkins] SVN: relstorage/trunk/relstorage/storage.py Support FileStorage iterators too

Martijn Pieters mj at zopatista.com
Wed Sep 7 08:48:00 EST 2011


Log message for revision 122741:
  Support FileStorage iterators too

Changed:
  U   relstorage/trunk/relstorage/storage.py

-=-
Modified: relstorage/trunk/relstorage/storage.py
===================================================================
--- relstorage/trunk/relstorage/storage.py	2011-09-07 13:25:23 UTC (rev 122740)
+++ relstorage/trunk/relstorage/storage.py	2011-09-07 13:47:59 UTC (rev 122741)
@@ -25,6 +25,7 @@
 from ZODB.BaseStorage import TransactionRecord
 from ZODB import ConflictResolution
 from ZODB import POSException
+from ZODB.FileStorage import FileIterator
 from ZODB.POSException import POSKeyError
 from ZODB.UndoLogCompatible import UndoLogCompatible
 from ZODB.utils import p64
@@ -1325,6 +1326,12 @@
         log.info("Counting the transactions to copy.")
         if isinstance(other, TransactionIterator):
             num_txns = len(other)
+        elif isinstance(other, FileIterator):
+            # Create copy and ask for that for it's length so we do not
+            # exhaust the original iterator
+            copy = FileIterator(other._file_name, other._start, other._stop, 
+                other._pos)
+            num_txns = len(list(copy))
         else:
             num_txns = len(list(other.iterator()))
         log.info("Copying the transactions.")



More information about the checkins mailing list