Re: [Zope-dev] dtml-in batching improved
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
On Wed, Jun 13, 2001 at 04:28:12PM -0700, Jean Lagarde wrote:
Good day all,
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
(more similar code removed) This is basically my patch #1. It makes previous-sequence-* and next-sequence-* available throughout the entire dtml-in loop. This sounds like a good fix, but people may rely on these variables being only set at resp. the start and end of the iteration. So this patch may break existing dtml code. That's why I suggested patch #2, which introduces new variables. Old code will continue to work, but people who want the problem fixed can use the newly introduced variables, which are available throughout the iteration. Ivo -- Drs. I.R. van der Wijk -=- Brouwersgracht 132 Amaze Internet Services V.O.F. 1013 HA Amsterdam -=- Tel: +31-20-4688336 Linux/Web/Zope/SQL Fax: +31-20-4688337 Network Solutions Web: http://www.amaze.nl/ Consultancy Email: ivo@amaze.nl -=-
Ivo, somehow I had missed the very start of the thread. I think that my change pretty much implements the third alternative you describe in your post, but for which you provided no patch (the one which defines the variables at the top and bottom only, because I leave the "if index==first or index==last" test). You are right that my change could break existing code, but I think not as badly as defining the variables for every iteration. In any case, I will keep the change in my version until I notice a side effect that I don't like. Cheers, Jean
-----Original Message----- From: Ivo van der Wijk Sent: Monday, June 18, 2001 7:31 AM
This is basically my patch #1. It makes previous-sequence-* and next-sequence-* available throughout the entire dtml-in loop.
This sounds like a good fix, but people may rely on these variables being only set at resp. the start and end of the iteration.
So this patch may break existing dtml code.
That's why I suggested patch #2, which introduces new variables. Old code will continue to work, but people who want the problem fixed can use the newly introduced variables, which are available throughout the iteration.
Ivo
participants (2)
-
Ivo van der Wijk -
Jean Lagarde