Re: [Pyobjc-dev] Some PyObC tweaks for using EOF and custom frameworks
Brought to you by:
ronaldoussoren
From: Pierce T. W. I. <pi...@ma...> - 2003-08-13 17:38:19
|
On Monday, August 11, 2003, at 01:19 PM, b.bum wrote: > On Sunday, August 10, 2003, at 12:07, Ronald Oussoren wrote: >> If all 'unvalidated' objects are an instance of EOFault we could try >> to add a category on that class. That would have to be implemented in >> a seperate C module, the code fragment below failed to compile when I >> added this to objc_support.m: >> >> @class EOFault; >> @interface EOFault (PyObjCSupport) >> -(PyObject*)__pyobjc_PythonObject__; >> @end > > > Actually, this could be done from the Python side via the > addClassMethod API in the objc module -- or, at the least, that code > can be used as a model for implementing this without using a category. > It would allow the method to be added to a class conditioned on > whether or not the class exists. > > If __pyobjc_PythonObject__ as implemented on NSObject will "just > work", then there is no need to provide an alternative implementation: > > % python > Python 2.3b1 (#1, Jul 27 2003, 10:44:20) > [GCC 3.3 20030304 (Apple Computer, Inc. build 1481)] on darwin > Type "help", "copyright", "credits" or "license" for more information. > >>> import objc > >>> from Foundation import * > >>> x = NSBundle.mainBundle() > >>> x.description() > u'NSBundle </usr/bin> (loaded)' > >>> objc.classAddMethods(NSBundle, [NSObject.description]) > >>> x.description() > u'<NSBundle: 0x35b120>' Ok, so I could do: objc.classAddMethods(EOFault,[NSObject. __pyobjc_PythonObject__]) Testing... So I removed by [obj self] call from pythonify_c_value, and I used this instead: objc.classAddMethods(EOFault,[Foundation.NSObject.__pyobjc_PythonObject_ _]) And that worked on single faults, but not array faults. I also got "None" for object.description() on a single fault. So it really only partially worked. Pierce |