Handling of Multiple :list's
Hello List, or should I say Hallo :List =) I'm trying to work out how to do, or even if it is possible, to handle two :lists within nested in statements... How would I make this reference the correct lists. <!--#in amountlist --> <!--#in marketinglist --> <dtml-call "REQUEST.set('amount',_['sequence-item'])"> // using amount list <dtml-call "REQUEST.set('dealer_no',_['sequence-item'])"> // using marketing list <!--#call amend_holding_table --> <!--#/in --> <!--#/in --> Thanks Julian Clark
Julian Clark wrote:
<!--#in amountlist --> <!--#in marketinglist --> <dtml-call "REQUEST.set('amount',_['sequence-item'])"> // using amount list <dtml-call "REQUEST.set('dealer_no',_['sequence-item'])"> // using marketing list <!--#call amend_holding_table --> <!--#/in --> <!--#/in -->
Eeek! This really should be a python script... parameters: amountlist, marketinglist for a in amountlist: for m in markinglist: context.amend_holding_table(amount=a,deal_no=m) what is amend_holding_table? DTML? ZSQL? cheers, Chris
Hi Chris... I don't know enough python yet, I've only just downloaded the latest runtime. gotta get me some learning now ;) I realised that I really didn't want (or need) to iterate the second loop inside the first loop. this was what I did in the end <!--#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 --> 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, can i just call it from within a dtml method? Thanks Julian ----- Original Message ----- From: "Chris Withers" <chrisw@nipltd.com> To: "Julian Clark" <Julian.Clarke@b-online.com.au> Cc: "zope" <zope@zope.org> Sent: Thursday, July 17, 2003 8:25 PM Subject: Re: [Zope] Handling of Multiple :list's Julian Clark wrote:
<!--#in amountlist --> <!--#in marketinglist --> <dtml-call "REQUEST.set('amount',_['sequence-item'])"> // using amount list <dtml-call "REQUEST.set('dealer_no',_['sequence-item'])"> // using marketing list <!--#call amend_holding_table --> <!--#/in --> <!--#/in -->
Eeek! This really should be a python script... parameters: amountlist, marketinglist for a in amountlist: for m in markinglist: context.amend_holding_table(amount=a,deal_no=m) what is amend_holding_table? DTML? ZSQL? cheers, Chris
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
Julian Clark wrote at 2003-7-17 08:20 +0800:
or should I say Hallo :List =)
I'm trying to work out how to do, or even if it is possible, to handle two :lists within nested in statements...
How would I make this reference the correct lists.
<!--#in amountlist --> <!--#in marketinglist -->
Look at the "dtml-in"s "prefix" attribute. By the way, the old "<!-- ... -->" syntax hurts my eyes. I much prefer the modern "<dtml-XXX>" syntax. I like even more ZPT and Python Scripts and nowadays use DTML only in special cases (for CSS, JavaScript, SQL, Emails). Dieter
participants (3)
-
Chris Withers -
Dieter Maurer -
Julian Clark