[Zope] How to set an 'index' in batch display?

dvl dvl <dvl@wanadoo.nl>
Sun, 17 Mar 2002 14:11:25 +0100


Hello

I got a problem where i think i have tried every batch-sequence
variable, but can't get this to work.

I have a database with two tables. Table1 contains searchterms and
image names (only for images that are linked to a searchterm). Table2
contains the names of _all_ images (many images are not referenced to
by a search term), their date and pagenumber. (The images are scans
from historical publications).
In a search screen i can search for terms, which yields a result
screen. The results link to a display screen, with the image name as
parameter (in the dtml-var 'im').

The display method uses a ZSQL Query with the following:
params: im="" date=""

select imagename, directory, date, page from table2 where

imagename like <dtml-sqlvar im type=string>

<dtml-if date>
OR date = { ts '<dtml-var "_.DateTime(date)" fmt=ISO>'}
</dtml-if>

order by date, page


I can use the following listing, using batches of 1, which gives me
all images for the appropriate day, starting with the first image of
that day.

<dtml-in expr="Query(im=im)">
<dtml-in expr="Query(date=(_.str(date)))" size=1 start=qs>

<dtml-in expr="Query(date=(_.str(date)))" next size=1 start=qs>
         <a href="<dtml-var URL><dtml-var sequence-query
            >qs=<dtml-var
            next-sequence-start-number>">
         Next image<br>
         </a>
</dtml-in>

<img src="<dtml-var imagename>.gif">

</dtml-in>
</dtml-in>

The 'Next' section gives me the opportunity to page through the pages
of the day (a Previous section is also planned). However, I want to
start viewing at the exact image that was referenced to from the
search screen. So what i want to do, is to set some sort of index and
start viewing from there with the possibility to page to other pages
for that day.

In other words:
The query already detects that image n6c117 is from date 02/02/1796.
<dtml-var count-date> even gives the correct number of images for that
day, let's say the count for date 02/02/1796 is 11 images: n6c111
through n6c121.

Basically i have two questions, i think:
How can i calculate the 'index' number of image n6c117 (that is: 7
from 11)
How can i set that index in the lines
<dtml-in expr="Query(date=(_.str(date)))" size=1 start=qs>
<dtml-in expr="Query(date=(_.str(date)))" next size=1 start=qs>

Things like 'start=im' etc don't seem to work here.


NB: A further complication (syntaxwise) is the fact that in Table1
image names are spelled in uppercast, eg: N6C111, in table2 in
undercast, as n6c111, so sometimes you might have to use constructs
like (_.string.lower(imagename)). The date=(_.str(date))) construction
is for similar reasons.

Thanks and cheers