A Method To My Madness?
Hi; I'm trying to implement a textbook example using a DTML Method with a <dtml-in> tag: <ul> <dtml-in expr="objectValues('DTML Document')"> <li><a href="&dtml-absolute_url;"><dtml-var title_or_id></a></li><br> </dtml-in> </ul> Pretty straight-forward stuff, but strangely it works within DTML Methods but *not* within DTML Documents. Other DTML Methods work just fine. What am I doing wrong? TIA, BenO
On Sat, Sep 08, 2001 at 09:45:57AM -0700, Ben Ocean wrote:
<dtml-in expr="objectValues('DTML Document')"> <li><a href="&dtml-absolute_url;"><dtml-var title_or_id></a></li><br> </dtml-in>
Pretty straight-forward stuff, but strangely it works within DTML Methods but *not* within DTML Documents. Other DTML Methods work just fine. What am I doing wrong?
Nothing. You do it all right, but you forgot that Documents and Methods have different namespace rules. A Method does not have its own namespace, so objectValues is applied to its (the Method's) container. But a Document has its own namespace, so objectValues is applied to the Document itself! And there is no subobjects to list by objectValues, so you got nothing. Inside DTML Document you would write <dtml-in expr="PARENTS[-1].objectValues('DTML Document')"> thus listing objects in Document's parent (e.i. its container). Oleg. ---- Oleg Broytmann http://www.zope.org/Members/phd/ phd@phd.pp.ru Programmers don't die, they just GOSUB without RETURN.
Hello Oleg, Saturday, September 08, 2001, 19:33:01, you wrote: [snip] OB> Nothing. You do it all right, but you forgot that Documents and Methods OB> have different namespace rules. A Method does not have its own namespace, OB> so objectValues is applied to its (the Method's) container. OB> But a Document has its own namespace, so objectValues is applied to the OB> Document itself! And there is no subobjects to list by objectValues, so you OB> got nothing. OB> Inside DTML Document you would write OB> <dtml-in expr="PARENTS[-1].objectValues('DTML Document')"> OB> thus listing objects in Document's parent (e.i. its container). .. except that PARENTS[-1] is the site root.. You're counting the wrong way.. PARENTS[1] (or is it PARENTS[0]?) would give you the container :-) -- Geir Bækholt web-developer/zopatista geirh@funcom.com funcom oslo | webdev-team <!-- PGPid : 0x90B47B20 -->
.. except that PARENTS[-1] is the site root.. You're counting the wrong way.. PARENTS[1] (or is it PARENTS[0]?) would give you the container
Or of course <dtml-in "aq_parent.objectValues('DTML Document)"> and then you dont need to worry about it being 0 or -1...
On Sat, Sep 08, 2001 at 12:11:22PM -0700, Zopista wrote:
except that PARENTS[-1] is the site root.. You're counting the wrong way.. PARENTS[1] (or is it PARENTS[0]?) would give you the container
I often forget which side is which :)
Or of course <dtml-in "aq_parent.objectValues('DTML Document)"> and then you dont need to worry about it being 0 or -1...
Wow! Excellent solution. Oleg. ---- Oleg Broytmann http://www.zope.org/Members/phd/ phd@phd.pp.ru Programmers don't die, they just GOSUB without RETURN.
At 08:14 PM 9/8/01 +0200, you wrote:
Hello Oleg, Saturday, September 08, 2001, 19:33:01, you wrote: [snip] OB> Nothing. You do it all right, but you forgot that Documents and Methods OB> have different namespace rules. A Method does not have its own namespace, OB> so objectValues is applied to its (the Method's) container. OB> But a Document has its own namespace, so objectValues is applied to the OB> Document itself! And there is no subobjects to list by objectValues, so you OB> got nothing. OB> Inside DTML Document you would write OB> <dtml-in expr="PARENTS[-1].objectValues('DTML Document')"> OB> thus listing objects in Document's parent (e.i. its container).
.. except that PARENTS[-1] is the site root.. You're counting the wrong way.. PARENTS[1] (or is it PARENTS[0]?) would give you the container
And the winner is.............0!!! Thank you very much, gentlemen. BenO
participants (4)
-
Ben Ocean -
Geir Bækholt -
Oleg Broytmann -
Zopista