[Zope] sequence-item: how do I use it in an expr?

Rik Hoekstra rik.hoekstra@inghist.nl
Wed, 04 Apr 2001 16:53:36 +0200


Gerrie Roos wrote:
> 
> I know I ask a lot of silly questions, at least I'm learning...In the
> following snippet 'build' is a list of integers.  Now I want to do
> 'prBuildInsertMethod' with all the values in 'build'.  To the untrained
> eye, it seems like this should work.  But Zope can't find variable
> 'sequence'...why?  How do I do it then?
> 
> <dtml-in builds>
>      <dtml-call expr="prBuildInsertMethod(buildNo=sequence-item)">
> </dtml-in>

this is a faq; the mailing list archives are a good resource for questions like
these.
That said: inside an expression sequence-item is interpreted as Python: sequence
minus item, so you have to escape it 

<dtml-call expr="prBuildInsertMethod(buildNo=_['sequence-item'])">

this is ugly. You may want to consider using a Python script, where you can loop
with

for item in builds:
    context.prBuildInsertMethod(item)

assuming that prBuilInsertMethod would also be a Python Script (for DTML Methods
a few additional tricks may be necessary

hth

Rik