dtml-with syntax question
So here's a question from a fairly new Zope developer: I think I am finally getting a decent handle on namespace issues in Zope, and I can now with the dtml-with tag with reasonable efficacy in simple situations. But I have run into something of a brick wall on one issue. What I would like to be able to do is something like this: <dtml-with objectName1> <dtml-var attribute1> <dtml-var attribute2> <dtml-var attribute3> <dtml-with folder.subFolder.objectName2> <dtml-var attribute1> </dtml-with> </dtml-with> Where objectName2 is actually an attribute of objectName1. I figure I _should_ be able to do this, and I'm sure I'm missing something obvious. But I spent about a half hour scanning the Zope.org site and the list archives and can't find an obvious example of this. Any thoughts, hints or HOWTOs? Thanks! //glw
"Geoffrey L. Wright" wrote:
Where objectName2 is actually an attribute of objectName1.
<dtml-with objectName1> <dtml-var attribute1> <dtml-var attribute2> <dtml-var attribute3> <dtml-with objectName2> <dtml-var attribute1> </dtml-with> </dtml-with>
The above should now work... ...if it doesn't please explain in what way ;-) cheers, Chris
Chris Withers writes:
"Geoffrey L. Wright" wrote:
Where objectName2 is actually an attribute of objectName1.
<dtml-with objectName1> <dtml-var attribute1> <dtml-var attribute2> <dtml-var attribute3> <dtml-with objectName2> <dtml-var attribute1> </dtml-with> </dtml-with>
The above should now work...
...if it doesn't please explain in what way ;-)
Hmmm... OK. Here is my relevant code, complete with resulting error message: <dtml-with sidebar_item> <dtml-var attribute1> <dtml-var attribute2> etc... <dtml-with gsi_content> <dtml-with inventory> <dtml-with attribute3> <dtml-var short_desc> </dtml-with> </dtml-with> </dtml-with> </dtml-with sidebar_item> And Zope sez: Error Type: KeyError Error Value: short_desc attribute1, attribute2 and attribute3 are all attributes of sidebar_item. If I change the <dtml-with attribute3> to read <dtml-with weepee_the_weewee> (where weepee_the_weewee is the actual name of the object I'm trying to refer to), then I see the short_desc attribute of weepee_the_weewee perfectly. Don't I have to do something in my syntax to indicate that I'm looking for the the value of attribute3 rather than an object with the literal id "attribute3"?
cheers,
Chris
Dazed & Confused, //glw
"\"Geoffrey L. Wright\"
Don't I have to do something in my syntax to indicate that I'm looking for the the value of attribute3 rather than an object with the literal id "attribute3"?
I'm sure someone will correct me if I'm wrong. But I believe you want: <dtml-with "_.getitem(attribute3)"> -- Tim Cook -- Cook Information Systems | Office: (901) 884-4126 8am-5pm CDT Free Practice Management Project Coordinator http://www.freepm.org OSHCA Founding Supporter http://www.oshca.org
Tim Cook writes:
I'm sure someone will correct me if I'm wrong. But I believe you want:
<dtml-with "_.getitem(attribute3)">
Haven't tried it in my code yet, but thanks to your post I found the section about _.getitem(). That'll come in handy all over the place, so many thanks for the pointer! //glw
participants (5)
-
"Geoffrey L. Wright" <Geoffrey L. Wright -
Chris Withers -
Geoffrey L. Wright -
Geoffrey L. Wright -
Tim Cook