[Pythonmac-SIG] gensuitemodule on OS X
Donovan Preston
dsposx@mac.com
Mon, 3 Mar 2003 11:38:40 -0800
--Apple-Mail-12--306356391
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=US-ASCII;
format=flowed
Hello, PythonMac. It's good to be back. Regarding modernizing
gensuitemodule for use on Mac OS X, Jack, I have been working on this
for a while (over a year in fact) but since I am doing it in my spare
time I haven't polished it to the point where it's generally useful. I
should have posted about it earlier, but I've been busy :-)
Jack Jansen wrote:
> I would love to do this in gensuitemodule, but there's bits and pieces
> I don't know. Maybe someone can enlighten me?
>
> 1. Where is the ascr/gdte described? What is the return value, just
> raw AEUT/AETE data, or is it somehow encoded in OSA objects?
It doesn't seem to be formally described in any Apple documentation, at
least not that I have been able to find. It seems to be a relatively
well known event in both the Frontier and Perl communities, and the
page that lead me to it's discovery is here:
http://use.perl.org/~pudge/journal/3454
As for the return value, it comes back as an object with a data
attribute containing the raw aete data. Check out this interactive
session with the MacPython IDE 2.3 framework build:
Python 2.3a1 (#1, Jan 21 2003, 13:46:55)
[GCC 3.1 20020420 (prerelease)]
Type "copyright", "credits" or "license" for more information.
MacPython IDE 1.0.1
>>> import aetools
>>> import sys
>>> sys.path.append('/Users/dsp/python/dist/src/Mac/Scripts')
>>> import gensuitemodule
for_
>>> mail = aetools.TalkTo('emal')
>>> mail._start()
>>> aete = mail.send("ascr", "gdte")
>>> decoded = gensuitemodule.decode(aete[1]['----'].data)
>>> gensuitemodule.compileaete(decoded, None, "Mail")
And after running compileaete and choosing all the correct folders, you
have a module for talking to Mail. Totally cool!
> 2. It appears there's a higher level interface too, because if I do
> "get dictionary" in the script editor some applications are indeed
> fired up, but some are not. So, it seems that sometimes the ascr/gdte
> event is used to get the dictionary, but sometimes it's grabbed from
> the resource fork. At least, it seems that way...
Yes, I believe there is a higher level C interface for doing this as
well. However, documentation is extremely lacking, and google is not
terribly helpful in this regard :( Here is what I know:
There appear to be two very similar functions, OSAGetAppTerminology and
ASGetAppTerminology, which one can theoretically use to get back what I
believe is the same object we got back in the interactive session
above. I have attached an archive with a very simple extension module I
was using to experiment with these APIs. I apologize in advance for
inflicting this code on the world, as it is very incomplete and barely
works.
What the differences are between the APIs I am not sure, and why it
works for some applications and not others I am also not sure. I think
at this point the main stumbling block is that PromptGetFile, which I
was using to get a filename to attempt to generate a suite module for,
doesn't allow you to select bundles. With this code I am able to select
InDesign and create a python module for it, and that's all I needed to
do, so I didn't push any farther with it ;-)
I'm not sure if Script Editor et al uses various methods for getting
terminology or just one; if it tries the above API, then tries sending
the ascr/gdte event and falls back to the resource fork if it doesn't
work...
> 3. Is there an API to get the "pick application" dialog that script
> editor puts up when you do a get dictionary? The way it seems to find
> scriptable applications all over the place I get the impression it
> works together with launch services or something...
I have no idea. This must be the case, because if you look at for
example Address Book, it's creator code is '????' (Look inside the
bundle at the PkgInfo file where the type and creator are cached; if
it's not there, look in the plist) and it's therefore impossible to
construct a TalkTo that talks to it. It must be possible, but the magic
required to do it is beyond me.
By the way, I submitted an OSCON proposal for a 45 minute talk on using
Python to send AppleEvents on OS X. Hopefully, if it gets accepted and
I therefore have to take the time to get some demos up and running with
something other than InDesign, I will have a justifiable reason for
working on this more. Also, there may be some people at the talk
(perhaps from Apple) who would be able to shed some more light on some
of these questions, and perhaps it would spark enough interest that
other people would start helping too. I think Guido is responsible for
picking proposals that get accepted, so let's hope he sees the value in
all this :-)
--Apple-Mail-12--306356391
Content-Disposition: attachment;
filename=pyosa.tgz
Content-Transfer-Encoding: base64
Content-Type: application/x-gzip;
x-unix-mode=0644;
name="pyosa.tgz"
H4sIAAAAAAAAA+1a3U/bSBB3uD4Q3wuP97iXUxsH+YJNPizBcSJ8tIcENGq4vnDIZ+wNuDi2tV63
jRASf/rNfsQxSVtUqQnVdX8iGnt2dnZ2Zj07a5OOk8zb0BYKy2pbjuMAtSyn2+XU2mwLKqBBQ8ty
NjutTkuzbMuxOhrqLNYsgTyjHkFIC7L0i3IgNhwuw6DlIuXxbx4M3AFNCF7I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