Re: [Pyobjc-dev] NibLoader.py: parsing nibs at runtime
Brought to you by:
ronaldoussoren
From: Ronald O. <ous...@ci...> - 2002-11-16 20:30:33
|
On Saturday, Nov 16, 2002, at 20:55 Europe/Amsterdam, Just van Rossum wrote: > > >> And while we're at it: it would be a killer feature if NibLoader could >> optionally use Python's introspection features to check that your >> subclass actually implements all needed methods and such, so that if >> you set NibLoader.DEBUG to true (or have that set automatically if the >> environment variable PY_NIBLOADER_DEBUG is set) your classes are >> checked for conforming to what the nib expects. Of course we can't go >> any further than method names and number of arguments, but it would >> still be a great tool. > > Right, this should actually be straightforward! What the > NibClassBuilder > metaclass currently does is add stub methods for actions not defined > in the > class itself, and add IBOutlets for outlets that haven't been defined > "manually". It would be easy to print a warning to stderr at > class-build-time if > an action isn't defined. I think this flag should be True by default, > though, > since you're supposed to implement them all anyway. If you _choose_ to > just keep > the noop stub, _then_ you should set the debug flag to false... If you choose to do nothing you might as wel write the empty method yourself (there is probably a reason for doing nothing). That way we can do away with the flag and always warn if you don't implement all actions. > > (I don't grok outlets just yet: are the default IBOutlet objects all > that are > ever needed, or are you supposed to provide them yourself?) The default IBOutlets are all that is ever needed. You can set specific types in Interface Builder, but those are all Objective-C classes and those are all represented the same way in the Objective-C runtime. I'd probably prefer to emit a warning when you do define IBOutlet objects over doing it when you don't. Never warning at al is probably best. BTW. outlets are implemented using attributes/member variables in ObjC code, IBOutlets perform the same task in PyObjC. Ronald |