[Pythonmac-SIG] creating a dictionary for an applescript app?

has hengist.podd at virgin.net
Fri Jun 22 10:38:46 CEST 2007


On 22 Jun 2007, at 02:01, tom wible wrote:

> tried your applet code:
>
> >>> playRec = praem.Applet.initwithname('playRec')
> >>> recList = playRec.callsub('listRecDict')
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File "praem.py", line 9, in callsub
>     self.event('ascrpsbr', {'snam': name, '----': args}).send()
>   File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ 
> python2.5/site-packages/aeosa/aem/send/send.py", line 101, in send
>     raise CommandError(err[0], err.args[1:] and err[1] or '', None)
> aem.send.send.CommandError: CommandError -1708: the AppleEvent was  
> not handled by any handler
>
> but i do have a handler:
>
>
> on listRecDict()
> 	set tdl to {}
> 	set n to 0
> 	repeat with rec in recList
> 		set n to n + 1
> 		set end of tdl to rec's toDict(n)
> 	end repeat
> 	return tdl
> end listRecDict
>
> is there something else that has to be done to get the handler  
> recognized?
> thanx

My bad, I forgot to lowercase the subroutine names in my Python  
script. Internally, AppleScript lowercases subroutine names unless  
they're written within pipes, e.g. 'FooBar' should be called as  
'foobar', '|FooBar|' as 'FooBar'. So the correct code should be:

playRec = Applet.initwithname('playRec')
playRec.callsub('initreclist', False)
recList = playRec.callsub('listrecdict')

HTH

has
-- 
http://appscript.sourceforge.net
http://rb-appscript.rubyforge.org
http://appscript.sourceforge.net/objc-appscript.html



More information about the Pythonmac-SIG mailing list