[Zope] ZODB parent

Shane Hathaway shane@digicool.com
Fri, 23 Feb 2001 01:01:01 -0500


"Randall F. Kern" wrote:
> 
> Thanks, but that doesn't actually work.  aq_inner.aq_parent has the same
> value as aq_parent.

If you're using acquisition correctly, they are actually different.

> The scenario is complicated.  Here's a diagram of the db:
> 
> root
>         a
>                 b
>         c
> 
> b.__of__ inserts c into the chain above b, yet c has a method that needs
> to find it's siblings when run in this strange context.

Acquisition builds up two chains simultaneously: the containment chain
and the context chain.  Context (aq_parent) varies while containment
(aq_inner.aq_parent) does not, unless you call __of__() directly. 
Examples:

root.a is a wrapper around a; root is both context and container.
root.a.b is a wrapper around b; root.a is both context and container.
root.a.b.c is a wrapper around c; root.a.b is context but root is
container.

So root.a.b.c.aq_inner.aq_parent is a wrapper around root.

So I suppose you're doing something like "my_object = b.__of__(c)".  If
c is a wrapper, obtained by simply getting root.c, my_object will be a
wrapper that uses b as context and the wrapper around c as containment.

Shane

> > -----Original Message-----
> > From: Chris McDonough [mailto:chrism@digicool.com]
> > Sent: Thursday, February 22, 2001 9:36 PM
> > To: Randall F. Kern; zope@zope.org
> > Subject: Re: [Zope] ZODB parent
> >
> >
> > aq_inner.aq_parent will probably work.
> >
> > ----- Original Message -----
> > From: "Randall F. Kern" <randy@spoke.net>
> > To: <zope@zope.org>
> > Sent: Thursday, February 22, 2001 11:54 PM
> > Subject: [Zope] ZODB parent
> >
> >
> > Is it possible to get the container (ObjectManager) an Item is in?
> >
> > aq_parent won't work for me, I need the actual container.
> >
> > Obviously I could store the path to the OM in the items
> > manage_afterAdd
> > (although catching changes to the OM might be hard), but I was hoping
> > for a cleaner solution.
> > -Randy
> >
> > _______________________________________________
> > Zope maillist  -  Zope@zope.org
> > http://lists.zope.org/mailman/listinfo/zope
> > **   No cross posts or HTML encoding!  **
> > (Related lists -
> >  http://lists.zope.org/mailman/listinfo/zope-announce
> >  http://lists.zope.org/mailman/listinfo/zope-dev )
> >
> >
> >
> 
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )