[Zope-dev] _getOb or __getattr__?
Jeffrey P Shell
jeffrey@Digicool.com
Tue, 27 Feb 2001 11:45:56 -0500
"Chris Withers" <chrisw@nipltd.com> wrote:
> Jeffrey P Shell wrote:
>>
>> _getOb and _setOb are for placing subobjects somewhere besides attributes
>> (which is the default implementation).
>
> When would __getattr__ be used then?
>
In what context? You could wire __getattr__ to call into _getOb (and
probably __getitem__ too, since that's also used in traversal and as a way
of getting non-Pythonic ID'd objects).
def __getattr__(self, attr):
return self._getOb(attr)
Until very recently, __getattr__ on persistent objects was like playing with
nuclear fire. But now, I *believe* it behaves properly, which means
__getattr__ gets called when it receives an unknown name. How that affects
Acquisition, I don't know.