[Pythonmac-SIG] noob question: handling protocols and files

Kevin Dangoor dangoor at gmail.com
Sat Aug 6 19:46:31 CEST 2005


On 8/5/05, Bob Ippolito <bob at redivi.com> wrote:
> You may have to do that with a get URL apple event handler, see here:
> http://developer.apple.com/documentation/Cocoa/Conceptual/
> Scriptability/Concepts/ScriptabilityOverview.html
> (you shouldn't need any Carbon)

Before I go chasing around the Apple docs a bit more to see if I'm
registering the *correct* event handler, can you confirm if I'm doing
the right thing here?

The first questionable thing is that the constant for the type of
event is defined in the Apple Events docs (and in the AppleEvents
python module) as 'gurl'. However, the Apple Event Manager method call
is asking for an unsigned long. Should I convert "gurl" to
1735750252L?

Here's the objC example from Apple's doc:
[appleEventManager setEventHandler:self
andSelector:@selector(handleGetURLEvent:withReplyEvent:)
forEventClass:kAEInternetSuite andEventID:kAEISGetURL];

Here's my translation to Python:
            sel = objc.selector(MacController.handleGetURLEvent_withReplyEvent_,
                signature="vO:O:")
            aem.setEventHandler_andSelector_forEventClass_andEventID_(self, 
                sel, 
                1735750252L, 1735750252L)

This is in my application delegate's applicationWillFinishLaunching_
method, which is where Apple recommended doing this. I can see that
this is getting called, but my handler itself doesn't get called.

I'm testing by just doing "open <URL with my protocol>" at the
commandline, which does bring my app to the front but does not call my
handler method. Assuming all of the above is kosher, I'll do some more
digging around to make sure that this is, in fact, the specific
handler I want.

Thanks for your help so far!
Kevin


More information about the Pythonmac-SIG mailing list