Re: [Pyobjc-dev] Controller Layer
Brought to you by:
ronaldoussoren
From: b.bum <bb...@ma...> - 2003-12-24 23:19:07
|
On Dec 23, 2003, at 5:00 PM, Ronald Oussoren wrote: > For some reason the instance of 'Converter' is an instance of > 'NSNotifying_Converter' during the call to 'getAmount', and > 'getAmount' is not recognized as a Python method which is causing > infinite recursion. The class of the object is probably changed to > implement some feature of KVO. That is exactly what is happening. As others have discovered, automatic KVO works leveraging posing type behavior to override the setters and getters such that change notification can be automated. Somewhat evil, yes, but it is efficient and transparent in the case where you aren't playing intense games with the runtime (as does PyObjC). > This is fixable by using libffi more agressively, although this may > have other negative effects. E.g., we should use libffi to find the > exact Python function to the method stub, instead of looking up the > Python method in the class when it is called. This would defeat the dynamic dispatch inherit to both objc and python, correct? I.e. if I write... x.doSomething() y.editTheRuntime() x.doSomething() ... and editTheRuntime() does exactly that, then the second invocation could lead to a completely different implementation of doSomething(). KVO is somewhat misnamed -- it isn't limited to key/value coding. That is the whole point behind doing some relatively low level edits to the runtime to make KVO work the way it does. By doing so, it breaks the dependency on the developer always changing the value through the NSKeyValueCoding methods, thus making change observation transparent to the usage of the class (as long as the developer uses the setters and getters, directly or indirectly, the changes will be observed). Could the existing functionality be modified such that the presence of the notifying posed class does not break the dispatch into Python? b.bum |