[Zope-dev] Getting parent within ZClass hierarchy
Steve Alexander
steve@cat-box.net
Fri, 09 Feb 2001 14:55:23 +0000
Arno Gross wrote:
> Easy question, but I couldn't find the answer.
> How can I access the id (or title) of the parent
> containing my current object?
>
> E.g.
>
> NewsContainer
> |---NewsCategory ( ZClass - ObjectManager)
> |---NewsItem (ZClass - CatalogAware)
>
> I'm looking for a method (Python script) in NewsItem, which give me the id or
> title of its parent.
>From DTML:
<dtml-with "aq_parent">
<dtml-var title_or_id>
</dtml-with>
From a PythonScript:
container.aq_parent.id
(if the PythonScript is a member of the NewsItem class)
context.aq_parent.if
(if the PythonScript is acquired from elsewhere)
This isn't really a zope-dev kind of question, as it is more about using
Zope in a basic kind of way. You should ask questions like this on
zope@zope.org instead.
--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net