[Zope-CMF] ZPT object parent?
Dieter Maurer
dieter@handshake.de
Wed, 28 Aug 2002 22:08:03 +0200
J C Lawrence writes:
>
> How do I get the parent folder of an object under ZPT?
>
> I have a ZPT repeat structure that is picking up all the objects of a
> certain criteria in all the folders below a certain point.
>
> <div tal:repeat="mytype python:here.portal_catalog (
> Type='MyEntry',
> path={'query':herePath},
> sort_on='created',
> sort_order='reverse')">
>
> When I then loop thru and display each one I want to give a link back to
> the parent folder that contained the object, not my current location
> (which could be many folder levels higher).
You can try:
<div tal:repeat...>
<tal:div tal:define="
myTypeObject mytype/getObject;
parent myTypeObject/aq_parent;
">
...
I am not sure that it will work.
The "aq_parent" may return the wrong object.
If it does, you need an internal method "getContainer"
with the definition:
def getContainer(obj): return obj.aq_inner.aq_parent
Dieter