| 1 | \section{\module{MiniAEFrame} ---
|
|---|
| 2 | Open Scripting Architecture server support}
|
|---|
| 3 |
|
|---|
| 4 | \declaremodule{standard}{MiniAEFrame}
|
|---|
| 5 | \platform{Mac}
|
|---|
| 6 | \modulesynopsis{Support to act as an Open Scripting Architecture (OSA) server
|
|---|
| 7 | (``Apple Events'').}
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 | The module \module{MiniAEFrame} provides a framework for an application
|
|---|
| 11 | that can function as an Open Scripting Architecture
|
|---|
| 12 | \index{Open Scripting Architecture}
|
|---|
| 13 | (OSA) server, i.e. receive and process
|
|---|
| 14 | AppleEvents\index{AppleEvents}. It can be used in conjunction with
|
|---|
| 15 | \refmodule{FrameWork}\refstmodindex{FrameWork} or standalone. As an
|
|---|
| 16 | example, it is used in \program{PythonCGISlave}.
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 | The \module{MiniAEFrame} module defines the following classes:
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 | \begin{classdesc}{AEServer}{}
|
|---|
| 23 | A class that handles AppleEvent dispatch. Your application should
|
|---|
| 24 | subclass this class together with either
|
|---|
| 25 | \class{MiniApplication} or
|
|---|
| 26 | \class{FrameWork.Application}. Your \method{__init__()} method should
|
|---|
| 27 | call the \method{__init__()} method for both classes.
|
|---|
| 28 | \end{classdesc}
|
|---|
| 29 |
|
|---|
| 30 | \begin{classdesc}{MiniApplication}{}
|
|---|
| 31 | A class that is more or less compatible with
|
|---|
| 32 | \class{FrameWork.Application} but with less functionality. Its
|
|---|
| 33 | event loop supports the apple menu, command-dot and AppleEvents; other
|
|---|
| 34 | events are passed on to the Python interpreter and/or Sioux.
|
|---|
| 35 | Useful if your application wants to use \class{AEServer} but does not
|
|---|
| 36 | provide its own windows, etc.
|
|---|
| 37 | \end{classdesc}
|
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 | \subsection{AEServer Objects \label{aeserver-objects}}
|
|---|
| 41 |
|
|---|
| 42 | \begin{methoddesc}[AEServer]{installaehandler}{classe, type, callback}
|
|---|
| 43 | Installs an AppleEvent handler. \var{classe} and \var{type} are the
|
|---|
| 44 | four-character OSA Class and Type designators, \code{'****'} wildcards
|
|---|
| 45 | are allowed. When a matching AppleEvent is received the parameters are
|
|---|
| 46 | decoded and your callback is invoked.
|
|---|
| 47 | \end{methoddesc}
|
|---|
| 48 |
|
|---|
| 49 | \begin{methoddesc}[AEServer]{callback}{_object, **kwargs}
|
|---|
| 50 | Your callback is called with the OSA Direct Object as first positional
|
|---|
| 51 | parameter. The other parameters are passed as keyword arguments, with
|
|---|
| 52 | the 4-character designator as name. Three extra keyword parameters are
|
|---|
| 53 | passed: \code{_class} and \code{_type} are the Class and Type
|
|---|
| 54 | designators and \code{_attributes} is a dictionary with the AppleEvent
|
|---|
| 55 | attributes.
|
|---|
| 56 |
|
|---|
| 57 | The return value of your method is packed with
|
|---|
| 58 | \function{aetools.packevent()} and sent as reply.
|
|---|
| 59 | \end{methoddesc}
|
|---|
| 60 |
|
|---|
| 61 | Note that there are some serious problems with the current
|
|---|
| 62 | design. AppleEvents which have non-identifier 4-character designators
|
|---|
| 63 | for arguments are not implementable, and it is not possible to return
|
|---|
| 64 | an error to the originator. This will be addressed in a future
|
|---|
| 65 | release.
|
|---|