Added section on passing contextual information to logging and documentation for...
[python.git] / Doc / library / miniaeframe.rst
blob5bf1b0724cf2930f1f3859bf33d563632d0832a0
2 :mod:`MiniAEFrame` --- Open Scripting Architecture server support
3 =================================================================
5 .. module:: MiniAEFrame
6    :platform: Mac
7    :synopsis: Support to act as an Open Scripting Architecture (OSA) server ("Apple Events").
10 .. index::
11    single: Open Scripting Architecture
12    single: AppleEvents
13    module: FrameWork
15 The module :mod:`MiniAEFrame` provides a framework for an application that can
16 function as an Open Scripting Architecture  (OSA) server, i.e. receive and
17 process AppleEvents. It can be used in conjunction with :mod:`FrameWork` or
18 standalone. As an example, it is used in :program:`PythonCGISlave`.
20 The :mod:`MiniAEFrame` module defines the following classes:
23 .. class:: AEServer()
25    A class that handles AppleEvent dispatch. Your application should subclass this
26    class together with either :class:`MiniApplication` or
27    :class:`FrameWork.Application`. Your :meth:`__init__` method should call the
28    :meth:`__init__` method for both classes.
31 .. class:: MiniApplication()
33    A class that is more or less compatible with :class:`FrameWork.Application` but
34    with less functionality. Its event loop supports the apple menu, command-dot and
35    AppleEvents; other events are passed on to the Python interpreter and/or Sioux.
36    Useful if your application wants to use :class:`AEServer` but does not provide
37    its own windows, etc.
40 .. _aeserver-objects:
42 AEServer Objects
43 ----------------
46 .. method:: AEServer.installaehandler(classe, type, callback)
48    Installs an AppleEvent handler. *classe* and *type* are the four-character OSA
49    Class and Type designators, ``'****'`` wildcards are allowed. When a matching
50    AppleEvent is received the parameters are decoded and your callback is invoked.
53 .. method:: AEServer.callback(_object, **kwargs)
55    Your callback is called with the OSA Direct Object as first positional
56    parameter. The other parameters are passed as keyword arguments, with the
57    4-character designator as name. Three extra keyword parameters are passed:
58    ``_class`` and ``_type`` are the Class and Type designators and ``_attributes``
59    is a dictionary with the AppleEvent attributes.
61    The return value of your method is packed with :func:`aetools.packevent` and
62    sent as reply.
64 Note that there are some serious problems with the current design. AppleEvents
65 which have non-identifier 4-character designators for arguments are not
66 implementable, and it is not possible to return an error to the originator. This
67 will be addressed in a future release.