From: Frank Illenberger <illenberger@ma...> - 2006-07-08 06:37:46
I just started working with pyobj and find it very exciting. But one
thing confuses me a bit:
I am subclassing an Objective-C class from Python. The documentation
says that one should be able to access python member variables of an
object via valueForKey:/setValue:forKey: from Objective-C. In my
application this works fine when the python script is initially
loaded, but after reloading it via execfile it throws the following
exception even though the variable "duration" exists.
NSExceptionHandler has recorded the following exception:
NSUnknownKeyException -- [<MERMyNewList 0xf76b1e0>
setValue:forUndefinedKey:]: this class is not key value coding-
compliant for the key duration.
1 -[WBLPart setValue:forUndefinedKey:]
2 _PyObjC_CallPython (in _objc.so)
3 _ffi_closure_helper_DARWIN (in _objc.so)
4 _ffi_closure_ASM (in _objc.so)
5 -[PWList writeReportWithBaseObjects:parameters:toPath:error:]
6 -[PWList refreshReport:]
7 -[NSToolbarButton sendAction:to:] (in AppKit)
8 -[NSToolbarButton sendAction] (in AppKit)
9 -[NSToolbarItemViewer mouseDown:] (in AppKit)
10 -[NSWindow sendEvent:] (in AppKit)
11 -[NSApplication sendEvent:] (in AppKit)
12 -[NSApplication run] (in AppKit)
13 _NSApplicationMain (in AppKit)
I initialize the python variables in the overridden init method:
self.duration = ""
The exception does not occur if I declare the variable the following
duration = objc.ivar("duration")
Does anybody have an idea why key value coding with python variables
does not work after reloading?