/Doc/library/miniaeframe.rst

http://unladen-swallow.googlecode.com/ · ReStructuredText · 68 lines · 44 code · 24 blank · 0 comment · 0 complexity · 0125a55a1776dcadd8b1e039e30f8d47 MD5 · raw file

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