[Zope] rendering image tags (corrected)

hamish@allan.tc hamish@allan.tc
22 Aug 2001 17:51:26 -0000


sorry - there was a mistake in the dtml-in expression in my earlier query. here 
it is corrected:

----

hi folks,

suppose i have some images in a folder, named image1, image2 and image3, and 
the following DTML method:

<dtml-in expr="['image1', 'image2', 'image3']">
<p><dtml-var expr="_.getitem(_['sequence-item'])"></p>
</dtml-in>

this yields something of the form:

<p><img src="http://localhost:8080/test/image1" alt="image one" height="32" 
width="90" border="0" /></p>
<p><img src="http://localhost:8080/test/image2" alt="image two" height="32" 
width="90" border="0" /></p>
<p><img src="http://localhost:8080/test/image3" alt="image three" height="32" 
width="90" border="0" /></p>

(incidentally, this is the case whether or not i pass 'true' to the 'render' 
argument of getitem()).

first question (the answer to which is probably obvious, but i'm new to zope):
- why does the following not yield the same result?

<dtml-in expr="['image1', 'image2', 'image3']">
<p><dtml-var sequence-item></p>
</dtml-in>

(yields: <p>image1</p>\n<p>image2</p>\n<p>image3</p>)

second question:
- i want to pass an extra argument to the image object. the following code 
works:

<dtml-in expr="['image1', 'image2', 'image3']">
<p><dtml-var expr="_.getitem(_['sequence-item']).tag(name=_['sequence-
item'])"></p>
</dtml-in>

yielding:

<p><img src="http://localhost:8080/test/image1" alt="image one" height="32" 
width="90" border="0" name="image1" /></p>
<p><img src="http://localhost:8080/test/image2" alt="image two" height="32" 
width="90" border="0" name="image2" /></p>
<p><img src="http://localhost:8080/test/image3" alt="image three" height="32" 
width="90" border="0" name="image3" /></p>

but this is based on knowledge that Image.__str__() calls tag(), which i do not 
want to rely upon.

instead i want to call the object in the same way as it is called when i use a 
simple tag such as '<dtml-var image1>'.

how do i achieve this?

(using expr="_.getitem(_['sequence-item'])(name=_['sequence-item'])", i.e., 
dropping the '.tag', yields an AttributeError of value __call__).

thanks in advance,
hamish


-- 
Get your firstname@lastname email for FREE at http://Nameplanet.com/?su