Its easy to create an infinite loop. To avoid these, do attribute lookups from the instance __dict__ rather than directly from self:
IOW, don't do: foo = self.foo or getattr(self, 'foo') (This can trigger another __getattr__ call) Instead do: foo = self.__dict__['foo'] (This won't cause another getattr call) As for examples, there is a complex one in the CMF Skinnable module and a simpler one in the Document module of my DocumentLibrary product. -Casey On Tuesday 03 December 2002 10:58 am, Maurizio Boriani wrote: > >>>>> "Casey" == Casey Duncan <[EMAIL PROTECTED]> writes: > > Casey> If you want an object to be able to handle calls to > Casey> undefined methods, you'll probably need to use a > Casey> __getattr__ hook. They can be a little tricky to get right > Casey> (you want to filter out names that start with "_" or "aq" > Casey> or else you'll be in trouble), and they don't have access > Casey> to acquisition, but they will allow you to intercept calls > Casey> to arbitrary names on an object. > > have you some examples or docs about this? I'm tring using it but my product > felt in an unfinisched loop. Any suggestion > > Casey> -Casey > > TIA, > baux > _______________________________________________ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )