Hi, I'm having some scoping issues with PARENTS. It doesn't seem to acknowledge with tags or anything else. For example, if I have the folder hierarchy: A B C D E and in the index_html document of C I say: <dtml-with E> <dtml-in PARENTS> <dtml-var "_['sequence-item'].id"><br> </dtml-in> </dtml-with> it produces: C B A when I actually want: E D A And if I say: <dtml-var "E.PARENTS"> then I get an error message. What am I doing wrong? Is there an easy way to make it behave like I want it to? Thanks in advance, Alice
Hi,
I'm having some scoping issues with PARENTS. It doesn't seem to acknowledge with tags or anything else. For example, if I have the folder hierarchy: A B C D E
and in the index_html document of C I say: <dtml-with E> <dtml-in PARENTS> <dtml-var "_['sequence-item'].id"><br> </dtml-in> </dtml-with>
it produces: C B A
That's because acquisition produces a namespace stack of A B C, so in reversed order PARENTS are BA if index_html is a DTML Method. If index_html is a DTML Document then PARENTS are CBA. Actually Zope should give a NameError if you call <dtml-with E>, as E per se is not accessible from C. If you want E, you should call <dtml-with "D.E">. So. if you call D.E from C's index_html then its PARENTS are still C, B, and A. The with tag does not seem to stack namespace upon the existing namespace stack.
when I actually want: E D A
And if I say: <dtml-var "E.PARENTS">
then I get an error message.
Yes, because PARENTS is not an attribute of E. It will generate an error anywhere.
What am I doing wrong? Is there an easy way to make it behave like I want it to?
This is a bit difficult to answer if you do not make clear what you want to attain? You could change the folder hierarchy to A D E B C or in your own hierarchy call C's index html from E. Rik
Thanks for explanation. Here's what I'm trying to do. I need to generate a table of contents that uses relative links. I'm doing the TOC recursively with a method called dtml_tree, and it works fine except for the relative links. So I want to write a method named relative_url that returns the url relative to the page that initially called dtml_tree. To do this, I need to access PARENTS for both the current object and the original object. There must be some way to do that, right? Here's the code for dtml_tree: <dtml-if "level<0"> <b><dtml-var title></b><br> <dtml-else> <dtml-in "_.range(level)"> </dtml-in> <dtml-if "id!=calledFrom.id"> <a href="<dtml-var relative_url>"><dtml-var title_or_id></a><br> <dtml-else> ><dtml-var title_or_id><<br> </dtml-if> </dtml-if> <dtml-in "objectItems(['Folder'])"> <dtml-with sequence-item> <dtml-with "_.namespace(level=level+1)"> <dtml-var dtml_tree> </dtml-with> </dtml-with> </dtml-in> And I call it from the standard header like this: <dtml-if "aq_parent.id!='root'"> <dtml-with "_.namespace(calledFrom=aq_parent, level=-1)"> <dtml-with "PARENTS[-3]"> <dtml-var dtml_tree> </dtml-with> </dtml-with> </dtml-if> Thanks again, Alice On Mon, 8 Nov 1999, Rik Hoekstra wrote:
Hi,
I'm having some scoping issues with PARENTS. It doesn't seem to acknowledge with tags or anything else. For example, if I have the folder hierarchy: A B C D E
and in the index_html document of C I say: <dtml-with E> <dtml-in PARENTS> <dtml-var "_['sequence-item'].id"><br> </dtml-in> </dtml-with>
it produces: C B A
That's because acquisition produces a namespace stack of A B C, so in reversed order PARENTS are BA if index_html is a DTML Method. If index_html is a DTML Document then PARENTS are CBA. Actually Zope should give a NameError if you call <dtml-with E>, as E per se is not accessible from C. If you want E, you should call <dtml-with "D.E">. So. if you call D.E from C's index_html then its PARENTS are still C, B, and A. The with tag does not seem to stack namespace upon the existing namespace stack.
when I actually want: E D A
And if I say: <dtml-var "E.PARENTS">
then I get an error message.
Yes, because PARENTS is not an attribute of E. It will generate an error anywhere.
What am I doing wrong? Is there an easy way to make it behave like I want it to?
This is a bit difficult to answer if you do not make clear what you want to attain? You could change the folder hierarchy to
A D E B C
or in your own hierarchy call C's index html from E.
Rik
Alice Gutman wrote:
Thanks for explanation. Here's what I'm trying to do. I need to generate a table of contents that uses relative links. I'm doing the TOC recursively with a method called dtml_tree, and it works fine except for the relative links.
I guess I don't understand why the url can't be absolute... just do: <dtml-if "id!=calledFrom.id"> <a href="<dtml-var absolute_url>"><dtml-var title_or_id></a><br> instead of: <dtml-if "id!=calledFrom.id"> <a href="<dtml-var relative_url>"><dtml-var title_or_id></a><br> -- Ethan "mindlace" Fremen you cannot abdicate responsibility for your ideology.
participants (3)
-
Alice Gutman -
Ethan Fremen -
Rik Hoekstra