On Mon, 2002-09-23 at 19:04, Johan Carlsson [Torped] wrote:
At 16:29 2002-09-23 +0000, Florent Guillaume said:
You didn't look a the code I pointed to you. Look at CMFCore/Skinnable to be precise (not everything is to be used of course).
* In __of__ you store the parent in a volatile attribute, * in __getattr__ you lookup the volatile attribute
This works as long as your object is not used in several different acquisition contexts.
Hi Florent, Would you care to elaborate on that last sentence? :-) Could you give an example when it wouldn't work?
Sure. If your object with special __of__ and __getattr__ is o and you do x = f.o # o.__of__(f) is called so f is stored in o._v_stuff y = f.g.o # o.__of__(f.g) is called so f.g is stored in o._v_stuff x['foo'] # o's __getattr__ finds f.g stored in _v_stuff and not f. But it's not necessarily a problem if you take care to use aq_inner. That depends on the use you have for the parent, really. Florent -- Florent Guillaume, Nuxeo (Paris, France) +33 1 40 33 79 87 http://nuxeo.com mailto:fg@nuxeo.com