-
Notifications
You must be signed in to change notification settings - Fork 1k
Plugin api
smari edited this page Sep 23, 2014
·
9 revisions
There are demos of the plugin API in mailpile/plugins/demos.py
If you want to know which plugins are currently registered, do print sys.plugins
from the textmode UI. To add a plugin, do append sys.plugins <name>
.
You can add arbitrary commands to Mailpile. See Command plugins
-
mailpile.plugins.register_commands(*plugins)
-plugins
is a list of one or more subclass ofCommand
.
An example command plugin:
class MyCommand(Command):
"""Do some very fun action"""
ORDER = ('', 0) # The command's order in the "help" output
# The first value in SYNOPSIS would be a shortform version, and
# the last contains a description of the paramters the function takes.
SYNOPSIS = (None, 'textui_commandname', 'webui_commandname', '')
HTTP_CALLABLE = ('GET', ) # Can be "GET", "POST", "PUT",... or empty for no HTTP interaction
HTTP_QUERY_VARS = {'q': 'search terms'} # A documented list of query variables taken
class CommandResult(Command.CommandResult):
def as_text(self):
# Overload the text printout. Also: as_json, as_html, ...
return "...".join(self.result)
def command(self):
args = self.args[:] # The arguments of the function
for q in self.data.get('q', []): # self.data contains HTTP query args
args.extend(q.split())
# ... do something ...
# Return some kind of JSON-serializable data structure...
return {}
See Extending Maipile's Configuration and Configuring Mailpile.
mailpile.plugins.register_config_variables(*args)
mailpile.plugins.register_config_section(*args)
-
mailpile.plugins.register_search_term(term, handler)
-handler
is a function that manages the search term. mailpile.plugins.register_data_kw_extractor(term, function)
mailpile.plugins.register_text_kw_extractor(term, function)
mailpile.plugins.register_meta_kw_extractor(term, function)
The internal contacts manager stores everything internally as VCards. It supports the addition of importers and exporters to populate the VCard store, and context providers which provide the contact manager with ephemeral data relating to the contact that is expected to change over time. See Contact plugins
-
mailpile.plugins.register_contact_importer(importer)
-importer
is subclass ofContactImporter
. -
mailpile.plugins.register_contact_exporter(exporter)
-exporter
is subclass ofContactExporter
. -
mailpile.plugins.register_contact_context_provider(provider)
-provider
is subclass ofContactContextProvider
.
Needs documenting.