Brendan Simon (eTRIX) wrote:
> 
> Cody Precord wrote:
>> Hello,
>>
>> On Jul 10, 2009, at 10:35 PM, Brendan Simon (eTRIX) wrote:
>>
>>> Brendan Simon (eTRIX) wrote:
>>> I registered the __geturl() event handler but it never gets called.

I forget to add self to the 'method' that's why it failed.  It does in
fact get called when the method is defined properly :)


I modified argv_emulation.py from the py2app package.
Added an event handler for the GetURL to extract the url and append to
sys.argv.  The code was based on the existing handler for OpenDocuments
event and the snippet that 'has' posted (changed typeUTF8Text to
typeWildCard as typeUTF8Text didn't exist on my system).

Here is the diff.

k9m:bootstrap $ diff argv_emulation.py.orig argv_emulation.py
10c10,11
<         kAEOpenDocuments, keyDirectObject, typeAEList, typeAlias
---
>         kAEOpenDocuments, keyDirectObject, typeAEList, typeAlias, \
>         kAEInternetSuite, kAEISGetURL, typeWildCard
25a27,29
>             #AE.AEInstallEventHandler(kAEInternetSuite, kAEISGetURL,
>             AE.AEInstallEventHandler('GURL', 'GURL',
>                 self.__geturl)
29a34,35
>             #AE.AERemoveEventHandler(kAEInternetSuite, kAEISGetURL)
>             AE.AERemoveEventHandler('GURL', 'GURL')
93a100,111
>         def __geturl(self, requestevent, replyevent): # event handler
>             try:
>                 listdesc =
requestevent.AEGetParamDesc(keyDirectObject, typeAEList)
>                 for i in range(listdesc.AECountItems()):
>                     desc = listdesc.AEGetNthDesc(i+1, typeWildCard)[1]
>                     url = desc.data.decode('utf8')
>                     sys.argv.append(url)
>             except Exception, e:
>                 print "argvemulator.py warning: can't unpack an GetURL
event"
>
>             self._quit()
>

Should I submit this as a patch somewhere ???

Thanks, Brendan.

begin:vcard
fn:Brendan Simon
n:Simon;Brendan
org:eTRIX pty ltd
adr:;;PO Box 306;St Kilda;VIC;3182;Australia
email;internet:brendan.si...@etrix.com.au
title:Managing Director
tel;work:+61-417-380-984
tel;cell:+61-417-380-984
x-mozilla-html:TRUE
version:2.1
end:vcard

_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig

Reply via email to