[Zope] Handling of Multiple :list's

Chris Withers chrisw@nipltd.com
Fri, 18 Jul 2003 15:28:32 +0100


Julian Clark wrote:
> I don't know enough python yet, I've only just downloaded the latest runtime. gotta get me some learning now ;)

Python is easier and more predictable than DTML.
ZPT is better than DTML for presentation.
Learn Python and ZPT. Don't go near DTML.

> <!--#in amountlist -->
> <dtml-call "REQUEST.set('listnum',_['sequence-index'])">
> <!--#in amountlist -->
> <dtml-if "_['sequence-index']==_['listnum']">
> <dtml-call "REQUEST.set('amount',_['sequence-item'])">
> <!--#/if -->
> <!--#/in -->
> <!--#in marketinglist -->
> <dtml-if "_['sequence-index']==_['listnum']">
> <dtml-call "REQUEST.set('dealer_code',_['sequence-item'])">
> <!--#/if -->
> <!--#/in -->
> <!--#call amend_holding_table -->
> <!--#/in -->

Urg! Stoppit! You're hurting me ;-) Now 've got REQUEST.set's in there and 
that's even worse!

> amend_holding table is a zSQL method
> Update mHoldingTable
> set
> amount = <dtml-sqlvar amount type=string>
> where
> dealer_code = <dtml-sqlvar dealer_code type=string>
> 
> How would I implement a python script to do this as you've suggested?

What are amountlist and marketinglist? where do they come from?

It seems they're two lists, one containing amounts, and the other containing the 
corresponding dealer codes. If so, try this:

for i in range(0,len(amountlist)):
    self.amend_holding_table(amount=amountlist[i],
                             dealer_code=marketinglist[i])

A bit shorter, isn't it? ;-)

 > can i just call it from within a dtml method?

Yes, or just hit it driectly with a URL/form submission/whatever...

cheers,

Chris