Re: [Zope] dtml-with & misbehaving strings
Thank you very much Jim for the clear answer. One last problem. If I want to iterate through this list, ie the depth of my drilling is NOT fixed, is there a simple way to do this via dtml. I want the following: <dtml-with "_.getattr(_[myproperty[0]], myproperty[1],.....,myproperty[x])"> Some reason tells me this is not possible with dtml alone. Is it time for me to give up and start hacking it with an external method? Thanks again for your help, Thomas <snip> Yup. The namespace lookup expression: "_[name]" takes a single name, but you have given it a string containing two names. I suggest that "Games.Whatup" is really a path expression. (Note that dots are legal in Zope names and therefore not a good choice for path separators, but that's beside the point.) There isn't a general way, in DTML currently to take a string containing a path and convert it two an object. (If there was, it would use '/'s as path sperators, as in "Games/Whatup".) Now, suppose your property was defined with "lines" or "tokens", which is a list of strings, and that you know that it always contained a two-part path, then you could use something like: <dtml-with "_.getattr(_[myproperty[0]], myproperty[1])"> This gets the name from the namespace corresponding to the first element if myproperty and then gets an attribute from the resulting object using the second element. </snip>
participants (1)
-
Thomas