argv emulation does not work for url open events. eg. click on webbrowser with link to "myurl:myinfo" does not put "myurl:myinfo" into sys.argv.
I modified the py2app argv_emulation.py to support this and have attached a patch. Is there a py2app developer who could have a look at this, test, and commit to the py2app source code so that it will be available in the next release. My python and Mac OS X skills are "raw" so please feel free to modify it in any way to improve it :) Thanks, Brendan.
--- argv_emulation.py.orig 2009-07-11 12:41:18.000000000 +1000 +++ argv_emulation.py.bjs 2009-08-14 09:33:40.000000000 +1000 @@ -7,7 +7,8 @@ import traceback from Carbon import AE from Carbon.AppleEvents import kCoreEventClass, kAEOpenApplication, \ - kAEOpenDocuments, keyDirectObject, typeAEList, typeAlias + kAEOpenDocuments, keyDirectObject, typeAEList, typeAlias, \ + kAEInternetSuite, kAEISGetURL, typeWildCard from Carbon import Evt from Carbon import File from Carbon.Events import highLevelEventMask, kHighLevelEvent @@ -23,10 +24,15 @@ self.__runapp) AE.AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments, self.__openfiles) + #AE.AEInstallEventHandler(kAEInternetSuite, kAEISGetURL, + AE.AEInstallEventHandler('GURL', 'GURL', + self.__geturl) def close(self): AE.AERemoveEventHandler(kCoreEventClass, kAEOpenApplication) AE.AERemoveEventHandler(kCoreEventClass, kAEOpenDocuments) + #AE.AERemoveEventHandler(kAEInternetSuite, kAEISGetURL) + AE.AERemoveEventHandler('GURL', 'GURL') def mainloop(self, mask = highLevelEventMask, timeout = 1*60): # Note: this is not the right way to run an event loop in OSX or @@ -91,6 +97,18 @@ self._quit() + 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() + return ArgvCollector() def _argv_emulation():
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