Chris McDonough wrote:
> > Sorry, just thought of another coupla questions:
> >
> > If x is an instance of my class, then:
> > If I do x.a = 1, is _setOb called?
> > If I do print x.a, is _getOb called?
> No in either case.
> _setOb shouldn't be used directly in the current ObjectManger
> implementation.  It doesn't populate the _objects list of the object manager
> on which it was called (your object won't show up).  Instead, _setObject
> should be called.

well, thankfully, I'm not going near __setattr__, _setOb or _setObject :-)
On the setting side, only __setitem__ is getting meddled with, and I'm guessing
there's not gotachas there?

Anyway, using these methods:

    # attribute - based traversal stuff
    def _getOb(self, name, default=_marker):
        print '_getOb:',name
            return higher_getOb(self,name)
            import sys
            print 'type:',sys.exc_type
            print 'value:',sys.exc_value
            raise AttributeError,name
    def __getattr__(self,name,higher_getattr=higher_getattr):
        #print '__getattr__:',name
            return higher_getattr(self,name)
        except AttributeError:
            import sys
            #print 'type:',sys.exc_type
            #print 'value:',sys.exc_value
            raise AttributeError,name

    def __getitem__(self,name,higher_getitem=higher_getitem):
        print '__getitem__:',name
            return higher_getitem(self,name)
        except KeyError:
            import sys
            #print 'type:',sys.exc_type
            #print 'value:',sys.exc_value
            raise KeyError,name would appear that unrestrictedTraverse first tries to use getattr and then
tries to use getitem to get a name. That much I can veryify from the code ;-)
However, it would appear that somewhere in a __getitem__ as implemented by
ZCatalog, _getOb ends up getting called. Which is a little confusing :-S

I think I know when the __get methods get called; same as normal python right?
But when, why, how and what by does _getOb and/org _getObject and/or anything
else I might be interested about in this space get called? ;-)

Thanks loads for the help so far,


Zope-Dev maillist  -  [EMAIL PROTECTED]
**  No cross posts or HTML encoding!  **
(Related lists - )

Reply via email to