RE: [Zope] rendering image tags (corrected)
This won't be a complete answer to your questions, but will get through some of the simpler parts as they pertain to Python. In [1] and [2], you're iterating over a sequence of strings, not objects; this is very important to realize. In [1], you use the getitem() method to retrieve the object whose id is provided by the string stored in sequence-item, which Zope then renders in the way you expect. In [2], you're simply retrieving the string. (Perhaps it may work as <dtml-in expr="[image1, image2, image3]">? That is, remove the inner quotes.) In [3], you're retrieving the object, and then trying to call an unnamed method (the method call is implied by the parentheses), passing a value to the argument 'name'. The __call__ method isn't set up to handle this situation. I don't think this behavior can be considered an error in the language. What I think you can do is create a new image subclass, and override the tag method to output a default name if none is given. Based on my admittedly scant knowledge of how Zope deals with Image objects, I believe it stands a good chance of working. Good Luck -- Keith -----Original Message----- From: hamish@allan.tc Sent: Wed 08/22/2001 10:51 [1] <dtml-in expr="['image1', 'image2', 'image3']"> <p><dtml-var expr="_.getitem(_['sequence-item'])"></p> </dtml-in> - why does the following not yield the same result? [2] <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>) [3] (using expr="_.getitem(_['sequence-item'])(name=_['sequence-item'])", i.e., dropping the '.tag', yields an AttributeError of value __call__).
participants (1)
-
Keith J. Farmer