[Zope-dev] dtml-in batching improved

Jean Lagarde jean.lagarde@eer-rc.com
Wed, 13 Jun 2001 16:28:12 -0700


Good day all,

I wouldn't consider myself as a Zope developper, but since that's where the
thread was...

I've read the thread with interest but so far all I've read in it are
workarounds that I do not find particularly nice. I did find a bug w/patch
in the collector (#1317), which I thought was meant to correct the problem,
but the patch has been applied to my version (2.3.2), and dtml-in evidently
still did not behave as expected. So I've looked at it more closely and
found what I think is a fix, but given my inexperience, I would like to know
if others think that I'm doing something wrong. I've tested the change for a
while on my application, and everything seems to work so far.

Here is the original code, with my annotated change (I deleted an if test in
two places):

                 for index in range(first,end):
                    # preset
                    kw['previous-sequence']= 0
                    kw['next-sequence']= 0 # now more often defined then
previously
                    #
                    if index==first or index==last:
                        # provide batching information
                        if first > 0:
                            pstart,pend,psize=opt(0,first+overlap,
                                                  sz,orphan,sequence)
     deleted this test -->  if index==first: kw['previous-sequence']=1
                            kw['previous-sequence-start-index']=pstart-1
                            kw['previous-sequence-end-index']=pend-1
                            kw['previous-sequence-size']=pend+1-pstart
                        try:
                            # The following line is a sneaky way to
                            # test whether there are more items,
                            # without actually computing a length:
                            sequence[end]
                            pstart,pend,psize=opt(end+1-overlap,0,
                                                  sz,orphan,sequence)
     deleted this test -->  if index==last: kw['next-sequence']=1
                            kw['next-sequence-start-index']=pstart-1
                            kw['next-sequence-end-index']=pend-1
                            kw['next-sequence-size']=pend+1-pstart
                        except: pass

                    if index==last: kw['sequence-end']=1

Cheers,

Jean