[Zope] how to pass <dtml-var sequence-item> to an external method from D TML?

Jim Washington jwashin@vt.edu
Mon, 06 Aug 2001 17:07:34 -0400


J. Cameron Cooper wrote:
>>
>>
>> <dtml-in getPropNames>
>>  <dtml-var sequence-item> <dtml-var getPropDescription("<dtml-var
>> sequence-item>")>
>> </dtml-in>
>>
>> Which throws the message:
>>    Invalid attribute name, """, for tag <dtml-var
>> getPropDescription("<dtml-var sequence-item>")>
>>
> DTML can either use things in its namespace or expressions, which are 
> little bits of Python. DTML is, unsurprisingly, not parsed in expressions.
> 
> You're familiar with things like <dtml-var property>. Expressions are 
> like <dtml-var expr="arbitrarystuff()">, which is also exactly like 
> <dtml-var "arbitrarystuff()">, but shorter. Those are the only ways to 
> call things in DTML. You can't mix and match, lest you drive the parser 
> mad.
> 
> In your case, it would be::
> 
>   Fool, the properties and thier descriptions are
>   <dtml-in getPropNames>
>      <dtml-var sequence-item> <dtml-var 
> "getPropDescription(sequence-item)">
>   </dtml-in>. Ha!
> 
>            --jcc
>        (foolha?)

But of course, that will not work, either.

<dtml-var "getPropDescription(sequence-item)"> will fail because python 
will try to subtract item from sequence before passing the argument.

You can either
<dtml-var "getPropDescription(_['sequence-item'])">
or use dtml-let to set sequence-item to something without a dash.

-- Jim Washington