[Zope-dev] This may be simpler...

Chris Withers chrisw@nipltd.com
Fri, 22 Sep 2000 09:57:35 +0100


Bernie Rossi wrote:
> def getContext(self):
>     # return the list of parents up to the project level in reverse order
>     . . .

Okay fair enough...

> def getAbsoluteURL(self, REQUEST):
>     """ Attempt to get the absolute URL of this object by building it
> manually"""

Why bother? there's a builtin method to do this for you!

>    <dtml-in "getContext()">
>       <option value="<dtml-var
> expr="getAbsoluteURL(REQUEST)">/manage_container"
>       <dtml-if expr="currId==getId()">
>        SELECTED
>       </dtml-if>
>       >
>       . . .
>       </option>
>    </dtml-in>

Maybe try this instead (assuming getContext returns a list of actual
objects):

    <dtml-in getContext>
       <option value="<dtml-var absolute_url>/manage_container"
       <dtml-if expr="currId==getId()">
        SELECTED
       </dtml-if>
       >
       . . .
       </option>
    </dtml-in>

I don't know where currId comes from so I'm not sure it does what it is
supposed to do...

> The function getContext does infact return a list of object instances
> (tested and okay) and also
> therefore the related REQUEST (I've assumed?).

Now why on earth would it do that? (It won't by the way, unless you code
it like that, and even then it would work in the way you've assumed)

> So that when we loop through
> the list (in the DTML), the 'context' of the 'current' object should change.

This is very confused...

> Thus we can interrogate each instance and do whatever we want (certainly in
> previous versions of Zope).

Well yeah, the dtml-in means that stuff inside it gets executed for each
object in the list.

Hope this helps,

Chris