[ZPT] CVS: Releases/Zope/lib/python/ZTUtils - Batch.py:1.6.14.1 Zope.py:1.7.14.1

Evan Simpson evan@zope.com
Fri, 15 Feb 2002 11:26:22 -0500


Update of /cvs-repository/Releases/Zope/lib/python/ZTUtils
In directory cvs.zope.org:/tmp/cvs-serv25553

Modified Files:
      Tag: Zope-2_5-branch
	Batch.py Zope.py 
Log Message:
Fix mismatch in orphan parameter, and broken computation of previous batches
with non-zero orphans.


=== Releases/Zope/lib/python/ZTUtils/Batch.py 1.6 => 1.6.14.1 ===
     def __of__(self, parent):
         return Batch(parent._sequence, parent._size,
-                     -1, parent.first + parent.overlap,
+                     parent.first - parent._size + parent.overlap, 0,
                      parent.orphan, parent.overlap)
 
 class LazyNextBatch(Base):
@@ -40,6 +40,20 @@
     
     def __init__(self, sequence, size, start=0, end=0,
                  orphan=0, overlap=0):
+        '''Encapsulate "sequence" in batches of "size".
+
+        Arguments: "start" and "end" are 0-based indexes into the
+        sequence.  If the next batch would contain no more than
+        "orphan" elements, it is combined with the current batch.
+        "overlap" is the number of elements shared by adjacent
+        batches.  If "size" is not specified, it is computed from
+        "start" and "end".  Failing that, it is 7.
+
+        Attributes: Note that the "start" attribute, unlike the
+        argument, is a 1-based index (I know, lame).  "first" is the
+        0-based index.  "length" is the actual number of elements in
+        the batch.
+        '''
 
         start = start + 1
 


=== Releases/Zope/lib/python/ZTUtils/Zope.py 1.7 => 1.7.14.1 ===
 class Batch(Batch):
     def __init__(self, sequence, size, start=0, end=0,
-                 orphan=3, overlap=0, skip_unauthorized=None):
+                 orphan=0, overlap=0, skip_unauthorized=None):
         sequence = LazyFilter(sequence, skip=skip_unauthorized)
         _Batch.__init__(self, sequence, size, start, end,
                         orphan, overlap)