Home | History | Annotate | Download | only in library
      1 
      2 :mod:`MiniAEFrame` --- Open Scripting Architecture server support
      3 =================================================================
      4 
      5 .. module:: MiniAEFrame
      6    :platform: Mac
      7    :synopsis: Support to act as an Open Scripting Architecture (OSA) server ("Apple Events").
      8 
      9 
     10 .. index::
     11    single: Open Scripting Architecture
     12    single: AppleEvents
     13    module: FrameWork
     14 
     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`.
     19 
     20 The :mod:`MiniAEFrame` module defines the following classes:
     21 
     22 
     23 .. class:: AEServer()
     24 
     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.
     29 
     30 
     31 .. class:: MiniApplication()
     32 
     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.
     38 
     39 
     40 .. _aeserver-objects:
     41 
     42 AEServer Objects
     43 ----------------
     44 
     45 
     46 .. method:: AEServer.installaehandler(classe, type, callback)
     47 
     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.
     51 
     52 
     53 .. method:: AEServer.callback(_object, **kwargs)
     54 
     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.
     60 
     61    The return value of your method is packed with :func:`aetools.packevent` and
     62    sent as reply.
     63 
     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.
     68 
     69