[Pythonmac-SIG] How to find correct Carbon module(s)?
Jack Jansen
Jack.Jansen at cwi.nl
Wed Feb 25 16:45:09 EST 2004
On 25 Feb 2004, at 10:46, Ronald Oussoren wrote:
>> I almost have a solution to this problem, but I need a bit of help
>> for the last bit.
>>
>> If I create a module Carbon.Carbon that imports all APIs from the
>> Carbon modules We're half way there:
>> >>> Carbon.Carbon.Window
>> <type '_Win.Window'>
>> >>> Carbon.Carbon.NewWindow
>> <built-in function NewWindow>
>> >>> Carbon.Carbon.NewWindow.__module__
>> '_Win'
>> The '_Win' bits aren't optimal, but that can probably be fixed into
>> Carbon.Win somehow.
>>
>> The bit I don't know how to do is the methods of the various objects.
>> They print the right thing when you repr() them:
>> >>> Carbon.Carbon.Window.ChangeWindowAttributes
>> <method 'ChangeWindowAttributes' of '_Win.Window' objects>
>> but you really want to refer to it as
>> "Carbon.Carbon.ChangeWindowAttributes".
>>
>> Does anyone have a suggestion for a way to loop over all the objects
>> in your namespace, check each object for being a class or type, for
>> each matching one that isn't a duplicate find all the methods and put
>> them in your namespace too?
>
> The trick I used in PyObjC is to hardcode the name of the module that
> will export an entity to the user in the extension module. The _objc
> extension defines a type 'informal_protocol', the user will never use
> _objc but will always import 'objc'. The tp_name of
> 'informal_protocol' therefore is 'objc.informal_protocol'. This
> correctly sets the __module__ attribute.
If I'm not mistaken that's the answer to the first question (The '_Win'
bits aren't optimal, but that can probably be fixed into Carbon.Win
somehow), but the real problem is the second one: how do I find all the
methods of all the objects, and put them in my namespace?
--
Jack Jansen, <Jack.Jansen at cwi.nl>, http://www.cwi.nl/~jack
If I can't dance I don't want to be part of your revolution -- Emma
Goldman
More information about the Pythonmac-SIG
mailing list