Commit 7b6791eb authored by Evan Simpson's avatar Evan Simpson

Merge fixes from Zope-2_5-branch.

parent 017c4630
...@@ -12,15 +12,15 @@ ...@@ -12,15 +12,15 @@
############################################################################## ##############################################################################
__doc__='''Batch class, for iterating over a sequence in batches __doc__='''Batch class, for iterating over a sequence in batches
$Id: Batch.py,v 1.6 2001/11/28 15:51:22 matt Exp $''' $Id: Batch.py,v 1.7 2002/02/15 16:26:56 evan Exp $'''
__version__='$Revision: 1.6 $'[11:-2] __version__='$Revision: 1.7 $'[11:-2]
from ExtensionClass import Base from ExtensionClass import Base
class LazyPrevBatch(Base): class LazyPrevBatch(Base):
def __of__(self, parent): def __of__(self, parent):
return Batch(parent._sequence, parent._size, return Batch(parent._sequence, parent._size,
-1, parent.first + parent.overlap, parent.first - parent._size + parent.overlap, 0,
parent.orphan, parent.overlap) parent.orphan, parent.overlap)
class LazyNextBatch(Base): class LazyNextBatch(Base):
...@@ -40,6 +40,20 @@ class Batch(Base): ...@@ -40,6 +40,20 @@ class Batch(Base):
def __init__(self, sequence, size, start=0, end=0, def __init__(self, sequence, size, start=0, end=0,
orphan=0, overlap=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 start = start + 1
......
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
############################################################################## ##############################################################################
__doc__='''Zope-specific versions of ZTUTils classes __doc__='''Zope-specific versions of ZTUTils classes
$Id: Zope.py,v 1.7 2001/11/28 15:51:22 matt Exp $''' $Id: Zope.py,v 1.8 2002/02/15 16:26:56 evan Exp $'''
__version__='$Revision: 1.7 $'[11:-2] __version__='$Revision: 1.8 $'[11:-2]
import sys, cgi, urllib, cgi import sys, cgi, urllib, cgi
from Tree import encodeExpansion, decodeExpansion, TreeMaker from Tree import encodeExpansion, decodeExpansion, TreeMaker
...@@ -141,7 +141,7 @@ class SimpleTreeMaker(TreeSkipMixin, SimpleTreeMaker): ...@@ -141,7 +141,7 @@ class SimpleTreeMaker(TreeSkipMixin, SimpleTreeMaker):
_Batch = Batch _Batch = Batch
class Batch(Batch): class Batch(Batch):
def __init__(self, sequence, size, start=0, end=0, 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) sequence = LazyFilter(sequence, skip=skip_unauthorized)
_Batch.__init__(self, sequence, size, start, end, _Batch.__init__(self, sequence, size, start, end,
orphan, overlap) orphan, overlap)
......
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