[Zope] How to correctly use the PARENTS object?

Gerrie Roos gerrie@trispen.com
Mon, 23 Apr 2001 13:21:01 +0200


Peter Sabaini wrote:

> I'm not sure myself how to use the PARENTS object myself, but I think
> you rather want to use the dtml-with tag. dtml-with tells Zope to
> "look somewhere else" for a name.
>
> Eg. something like this should work:
>
> <dtml-with Bugsmail>
>   <dtml-getRecipients>
>    ...
>   </dtml-in>
> </dtml-with>
>
> Hth,
> peter.
>
> On Mon, 23 Apr 2001, Gerrie Roos wrote:
>
> > I've struggled with this long enough to justify asking help...I've been
> > through the manuals, FAQ's etc, but somehow my understanding of PARENTS
> > object is incomplete...
> >
> > I have the following directory structure:
> >
> > Bugs
> >         Interface
> >                 Insert
> >                         sendMail - a DTML Document
> >                 BugsMail
> >                         getRecipients - a Z SQL Method
> >
> > I'd like to call and iterate over the results of getRecipients from
> > sendMail.  So I tried the following in sendMail:
> >
> > <dtml-in PARENTS[1].BugsMail.getRecipients>
> >         <dtml-var someFieldReturnedByGetRecipients>
> > </dtml-in>
> >
> > ...and I get a KeyError for PARENTS[1].BugsMail.getRecipients....
> >
> > I tried various other options (albeit somewhat blindly/desparately), eg.
> > putting the whole PARENTS thing in an expression, etc...What am I
> > missing?
> >
> > What other options are there to traverse a path in a dtml-statement, or
> > to do what I want to do here?
> >
> > Please help, I'm pretty new to this...
>
> --
>
> _________________________________________________
> peter sabaini, mailto: sabaini@niil.at
> -------------------------------------------------

Thanks Peter...it works, but I've still got problems...

in getRecipients, I use <dtml-var > to access some other dtml-docs and Z-SQL
methods that are in
the BugsMail directory, but they can not be found from within getRecipients!
If I just directly view getRecipients it works fine, but as soon as
getRecipients is called from somewhere else using the method you suggested,
the objects in the BugsMail directory seems to be out of the namespace.

So I actually want to call an object in a totally different branch of the
Zope tree, and it must be able to access its own default namespace as well...

I even tried another <dtml-with BugsMail> tag in the getRecipients file to
really bring accross my intention of wanting to call other objects in the
BugsMail directory, but not only does this seem clumsy, it also doesn't
work...am I still making sense?