[Zope] Acquiring parent objects through BTrees

Joseph Barillari jbarilla@princeton.edu
Tue, 7 Aug 2001 22:08:42 -0400


--vtzGhvizbBRQ85DL
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Hello,

I would like to know if it is possible for an object stored in a BTree
to use acquisition to see its parent object (either the BTree itself
or the object that holds the BTree).=20

Here's an example of what I've tried:

Python 2.1.1 (#1, Jul 29 2001, 19:04:01)=20
[GCC 2.96 20000731 (Red Hat Linux 7.1 2.96-85)] on linux2
Type "copyright", "credits" or "license" for more information.
>>> from Acquisition import Implicit
>>> from BTree import BTree
>>>=20
>>> class A(Implicit):
=2E..     pass
=2E..=20
>>> class B(Implicit):
=2E..     pass
=2E..=20
>>> class D(Implicit, BTree):
=2E..     pass
=2E..=20
>>> a =3D A()
>>>=20
>>> a.d =3D D()
>>> a.d     =20
<D instance at 8118330>
>>> a.d.aq_parent
<A instance at 8114c28>
>>> a.d[1] =3D B()
>>> a.d[1]     =20
<B instance at 8114c18>
>>> a.d[1].aq_parent
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
AttributeError: aq_parent

The Acquisition machinery has no problem with the regular
objects. Class D, which wraps a BTree and implicit acquisition, lets
the BTree see its parents, but an acquisition-enabled object placed in
an acquisition-enabled BTree still can't see its parent.

Any suggestions? Or is this a bad idea? Should I implement another
mechanism? The number of objects stored in the BTrees in the final
product is unlikely to be more than a few hundred, so another data
type might work.

Thanks,

Joe

--vtzGhvizbBRQ85DL
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE7cJ8pIV4b0vah+jcRAoSOAJ9TPe7TcoRnbZaMCg4Nqw48SeJtFQCeK+z0
un8ucXYFWADmOG9TBolQKIQ=
=uPfL
-----END PGP SIGNATURE-----

--vtzGhvizbBRQ85DL--