[Zope-DB] ZSQL, sum() and you
Tom Jenkins
tjenkins@devis.com
Tue, 04 Sep 2001 08:38:07 -0400
Mitch Pirtle wrote:
> Hi Zopistas,
>
> The winning answer was from Pavel V. Piankov
> [pashah@cosmos-mebel.spb.ru] who had the following angle on life:
>
> <dtml-call "REQUEST.set('total',0)">
> <p>
> <dtml-in "zsql.dbGetSalary(_,_.None)">
> Name: <dtml-var name> - <dtml-var salary> salary<br>
> <dtml-call "REQUEST.set('total',total+_.float(salary))">
> </dtml-in>
> Total: <dtml-var total>
> </p>
>
> ..and in the process taught me a little about keeping variables around
> in DTML -;^>= Thanks to Pavel for the help, I have agonized over this
> for a humiliatingly unacceptable amount of time...
>
> (forehead slap)
>
Well, you could do it that way, but the dtml-in tag has a lot of power
and is actually ready for you to do exactly what you want...
<p>
<dtml-in "zsql.dbGetSalary(_,_.None)">
Name: <dtml-var name> - <dtml-var salary> salary<br>
<dtml-if sequence-end>
Total: <dtml-var total-salary>
</dtml-if>
</dtml-in>
</p>
--
Tom Jenkins
devIS - Development Infostructure
http://www.devis.com