This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
devel:blueprints:mailin [2009/01/30 10:45] morten |
devel:blueprints:mailin [2009/02/02 12:08] (current) morten add link to another blueprint |
||
---|---|---|---|
Line 29: | Line 29: | ||
The plugin must expect the ''payload'' object to be a message object from [[http://docs.python.org/library/email.html|Python's standard email library]]. | The plugin must expect the ''payload'' object to be a message object from [[http://docs.python.org/library/email.html|Python's standard email library]]. | ||
+ | |||
+ | ==== Loading plugins ==== | ||
+ | * MailIn core will load plugin modules according to its configuration file. | ||
+ | * All plugin modules must be listed in a specific configuration option, separated by spaces or colons. | ||
+ | * suffix wildcards should be allowed, such that specifying ''"nav.mailin.plugins.*"'' will result in the loading of all modules in the ''nav.mailin.plugins'' package. | ||
+ | * A plugin module that fails to import into the Python interpreter shall be ignored by the core, and an exception logged (including a full traceback). | ||
+ | |||
+ | ==== Configuration ===== | ||
+ | Example configuration file: | ||
+ | <code> | ||
+ | [mailin] | ||
+ | # What plugins to load | ||
+ | plugins = nav.mailin.plugins.* | ||
+ | |||
+ | # Global authorization check (header regexp pattern) | ||
+ | # check to see that uit.no is in the Received headers | ||
+ | authorization = ^Received:.*uit\.no | ||
+ | |||
+ | # Plugin specific options | ||
+ | [nav.mailin.plugins.whatsup] | ||
+ | plugin_specific_value=foo | ||
+ | </code> | ||
+ | |||
+ | ===== API usage ===== | ||
+ | The following Python / NAV libraries should be used for various aspects of the program: | ||
+ | ^ api ^ for what ^ | ||
+ | | ''email'' | Parsing email payloads into Python objects that will be passed around internally | | ||
+ | | ''logging'' | Any logging should be performed using named loggers from Python's logging library | | ||
+ | | ''nav.event'' | Creating and posting events to NAV's event queue | | ||
+ | |||
+ | As of this writing, there is no API to create custom event type and alert type hierarchies in the NAV database. This will be added as [[https://blueprints.launchpad.net/nav/+spec/event-type-creation-api|a separate blueprint in Launchpad]]. |