[Zope] tuples in DTML

Michael Bernstein webmaven@lvcm.com
Wed, 27 Dec 2000 12:25:25 -0800


Max M wrote:
> 
> From: webmaven@zope.org [mailto:webmaven@zope.org]On Behalf Of Michael
> Bernstein
> 
> ><dtml-in "External_Method(REQUEST)">
> >  <dtml-var sequence-item><br>
> ></dtml-in>
> 
> >Which (of course) displays the list as an single item along
> >with each of the strings:
> 
> >  ['list item 1', 'list item 2', 'list item 3']
> >  String 1
> >  String 2
> >  String 3
> 
> >Now, how do I iterate over the list in DTML?
> 
> <dtml-call REQUEST.set('the_list', External_Method(REQUEST)[0])>
> <dtml-in the_list>
>     blah blah .... <dtml-var sequence-item>
> <dtml-in>
> 
> Something like the above ought to work.

Mmm, It doesn't seem quite right. If I do it that way, I'll
have to run the external method more than once, and it's a
relatively expensive method. I'm opening an HTTP connection
and processing the page to extract the data that is getting
put into the tuple.

What if I do:

<dtml-call "REQUEST.set('the_tuple',
External_Method(REQUEST))">
 <dtml-call "REQUEST.set('the_list', the_tuple[0])">
  <dtml-in the_list>
   <b><dtml-var sequence-item></b><br>
  </dtml-in>
 <dtml-var "the_tuple[1]"><br>
 <dtml-var "the_tuple[2]"><br>
 <dtml-var "the_tuple[3]"><br>

Ok, this works!

Thanks for the help,

Michael Bernstein.