Chris Withers wrote:
> I need a product with custom attribute getting code and so looked to the
> BTreeFolder product for inspiration.
> It implements both __getattr__ and _getOb which appear to do roughly the same
> What's the difference?
_getOb() is part of the ObjectManager interface. If you want to store
objects in your special ObjectManager in a special way, you override
_getOb(), _setOb(), and _delOb(). (I didn't check the spelling--see
However, if you store objects in your ObjectManager in a different way
than using setattr(self, name, value), acquisition won't find your
subobjects because acquisition only looks at object attributes. It
doesn't know anything about _getOb(). (And it's not a good idea to
teach it to use _getOb(); think what it would be like if a Xeon ran like
Overriding __getattr__() lets you make acquisition work again. However,
as Jeffrey said, until a few months ago it was forbidden. Then Jim
fixed it. Now it's used extensively by BTreeFolders, Transparent
Folders, and even the CMF. However, every time the acquisition
machinery calls a __getattr__() you get a performance hit in the range
of a few microseconds. But the products I listed try hard to minimize
that impact, so it's not enough of an issue to warrant a C
BTreeFolder.py provides a base class that doesn't have __getattr__().
You can use that if you think __getattr__() is slowing down your site.
The derived class is what most people use because it provides the full
Zope-Dev maillist - [EMAIL PROTECTED]
** No cross posts or HTML encoding! **
(Related lists -