[Zope] Bothered by batches

Nolan Darilek nolan_d@bigfoot.com
Sun, 25 Mar 2001 09:07:53 -0600


I've recently begun trying to figure out how batches work, but what
appears simple is instead causing massive problems, and I really don't
know what's wrong.

I have the following snippets of DTML in an index_html:

<dtml-unless first>
<dtml-call "REQUEST.set('first', 0)">
</dtml-unless>
<dtml-unless batchsize>
<dtml-call "REQUEST.set('batchsize', 2)">
</dtml-unless>
. . .
<dtml-in "jobs.objectValues()" size=batchsize start=first>
. . .
</dtml-in>

Then I have a BatchAdjustForm method which isn't a form anymore due to
recent changes, but it looks somewhat like this (note that the text
entry field will probably be nuked soon):

<table>
<tr>
<td>
<div align="left">
<dtml-if previous-sequence>
<a href="<dtml-var URL><dtml-var sequence-query>first=<dtml-var previous-sequence-start-number>&batchsize=<dtml-var batchsize>"><[Previous]</a>
<dtml-else>
<[Previous]
</dtml-if>
</td>
<td>
First:&nbsp;
<input type="text" name="first">
</td>
<td>
Size:&nbsp;
<select name="batchsize:int">
<option value="5">5</option>
<option value="10">10</option>
<option value="50">50</option>
<option value="100">100</option>
</select>
</td>
<td>
<div align="right">
<dtml-if next-sequence>
It worked!
<dtml-else>
[Next]>
</dtml-if>
</td>
</tr>
</table>

First of all, you'll probably notice that the batchsize is set
insanely small. This app is basically a job board, and is meant to
iterate through a list of jobs and extract batches. Until recently I
had never tested the batch functionality, but yesterday I added 6 jobs
to the board and, despite having set the batchsize to 5, all 6
showed. Dropping the batchsize to 4 has the same effect, but 3 or
lower works as expected; I'll see 3 items, 2, etc. Maybe I don't
understand how size= works?

Also, the BatchAdjustForm simply doesn't work. I consulted the batch
example in the Zope Book, and borrowed quite a bit from it, but
nothing seems to work. As you can probably see, I tried to simplify
the 'next' navigation link to print 'It worked!' and avoid using the
code I used for the 'previous' link, but this doesn't seem to ever
appear, despite the fact that I'm only displaying a few of the 6 jobs
currently in my sample database.

Any ideas? This isn't a major problem, but it's one of the last which
I'm experiencing with this project and it really annoys me that I
can't even get a simple batch query to work. :)