Lupus Yonderboy wrote:
I have tried hooking __getattr__ and have a hard time avoiding recursion; I have taken a look at the ever-productive Shane Hathaway's TransparentFolder product as well but I think I am let down by my lack of understanding of the particulars of acquisition.
Here are a few hints for avoiding recursion in __getattr__(): - Every attribute __getattr__ accesses that is expected to be in self.__dict__ should also be a class attribute. - Use self.__dict__.get(). - The "self" passed to __getattr__ is *not* wrapped, as it is for other methods, meaning you can't access anything in the object's context from __getattr__. CMF uses a combination of __of__(), volatile attributes, and Zope's threading model to get around this. Also, be sure optimize, because __getattr__ gets called *a lot*. In some cases, I've measured it getting invoked hundreds of thousands of times in a single request! Shane