-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 kevin7kal wrote:
That did not work for me either. It was also suggested that I try inheriting from folder rather than re-inventing folder. Still no dice. I think there is something that I don't understand about acquisition and context. Why can an object be placed into context if it is stored as a simple attribute of another object, but not if it is an element in a list? Or what must be done differently when the objects are elements in a list?
The piece of the picture you are missing is that the magic of acquisition happens in the 'getattr' hook: acquisition-aware objects create the wrapper (via '__of__') for objects fetched from them via attribute access. Containers which want to provide the same semantics for 'getitem' access have to call '__of__' directly themselves. For objects derived from OFS.ObjectManager, that responsibility is delegated to the '_getOb' method. Standard folders store their items as attributes, and so their '_getOb' doesn't have to do anything special:: def _getOb(self, id, default=_marker): if id[:1] != '_' and hasattr(aq_base(self), id): return getattr(self, id) if default is _marker: raise AttributeError, id return default A BTreeFolder, however, does not store items as attributes; its '_getOb' looks like:: def _getOb(self, id, default=_marker): """Return the named object from the folder. """ tree = self._tree if default is _marker: ob = tree[id] return ob.__of__(self) else: ob = tree.get(id, _marker) if ob is _marker: return default else: return ob.__of__(self) Tres. - -- =================================================================== Tres Seaver +1 202-558-7113 tseaver@palladion.com Palladion Software "Excellence by Design" http://palladion.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2.2 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFExAHA+gerLs4ltQ4RAhl5AJwJkRws7ISOvGUt0XP3++opMp3H9ACgiCGQ n41bgMeDpOE/VCI/EBJ/j3M= =ZmGA -----END PGP SIGNATURE-----