[Zope] How do I access an item in a list from dtml?

Pavlos Christoforou pavlos@gaaros.msrc.sunysb.edu
Wed, 13 Oct 1999 16:10:48 -0400 (EDT)


On Wed, 13 Oct 1999, Gustin Kiffney wrote:

> Example: I'm passing the following:
> parms=['item1','item2','item3']
> and the Pythonic way to access an item of this list would be simply
> parms[0] 
> or 
> parms[1]
> etc.
> 
> But when I try <dtml-var parms[0]>
> I get a KeyError for parms[0].
> Doing <dtml-var parms> shows the list all right.  I can interate over the list
> with 
> <dtml-in parms>
> all right also.  But I need to get particular items of the list and cannot
> figure out how to do that.

Try:

<dtml-var "parms[0]">

<dtml-var expr="parms[0]"> is actually the correct expression but for
convinience <dtml-var ...> will call the argument if it is callable. Use
quotes whenever you need to suplly arguments etc. 
Pavlos