Modoboa provides a simple API to interact with events. It understands two kinds of events:
Listening to a specific event is achieved as follow:
from modoboa.lib import events
def callback(*args):
pass
events.register('event', callback)
You can also use the custom decorator events.observe:
@events.observe('event')
def callback(*args):
pass
event is the event’s name you want to listen to, callback is the function that will be called each time this event is raised. Each event impose to callbacks a specific prototype to respect. See below for a detailled list.
To stop listening to as specific event, you must use the unregister function:
events.unregister('event', callback)
The parameters are the same than those used with register.
Read further to get a complete list and description of all available events.
Raised when a new account is created.
Callback prototype:
def callback(account): pass
Raised when an existing account is deleted.
Callback prototype:
def callback(account): pass
Raised when an existing account is modified.
Callback prototype:
def callback(oldaccount, newaccount): pass
Raised just before a user tries to create a new object.
Callback prototype:
def callback(user): pass
Return True or False to indicate if this user can respectively create or not create a new Domain object.
When an account is being modified, this event lets extensions check if this account is concerned by a specific form.
Callback prototype:
def callback(account, form): pass
Callbacks listening to this event must return a list containing one Boolean.
Raised when a new domain is created.
Callback prototype:
def callback(user, domain): pass
Raised when a new mailbox is created.
Callback prototype:
def callback(user, mailbox): pass
Raised when an existing domain is about to be deleted.
Callback prototype:
def callback(domain): pass
Raised when an existing mailbox is about to be deleted.
Callback prototype:
def callback(mailbox): pass
Raised when a new domain alias is created.
Callback prototype:
def callback(user, domain_alias): pass
Raised when an existing domain alias is about to be deleted.
Callback prototype:
def callback(domain_alias): pass
Raised when a domain has been modified.
Callback prototype:
def callback(domain): pass
Raised just after an extension has been disabled.
Callback prototype:
def callback(extension): pass
Raised just after an extension has been activated.
Callback prototype:
def callback(extension): pass
Let extensions add new forms to the account edition form (the one with tabs).
Callback prototype:
def callback(user, account): pass
Callbacks listening to the event must return a list of dictionnaries, each one must contain at least three keys:
{"id" : "<the form's id>",
"title" : "<the title used to present the form>",
"cls" : TheFormClassName}
Let extensions add extra content into the admin panel.
Callback prototype:
def callback(user, target, currentpage): pass
Callbacks listening to this event must return a list of string.
Let extensions add new forms to the domain edition form (the one with tabs).
Callback prototype:
def callback(user, domain): pass
Callbacks listening to the event must return a list of dictionnaries, each one must contain at least three keys:
{"id" : "<the form's id>",
"title" : "<the title used to present the form>",
"cls" : TheFormClassName}
When an account is beeing modified, this event is raised to fill extra forms.
Callback prototype:
def callback(user, account, instances): pass
When a domain is beeing modified, this event is raised to fill extra forms.
Callback prototype:
def callback(user, domain, instances): pass
Some places in the interface let plugins add their own announcement (ie. message).
Callback prototype:
def callback(target): pass
Callbacks listening to this event must return a list of string.
Let extensions define new administrative roles.
Callback prototype:
def callback(user): pass
Callbacks listening to this event must return a list of 2uple (two strings) which respect the following format: (value, label).
Let extensions add static content (ie. CSS or javascript) to default pages. It is pretty useful for functionalities that don’t need a template but need javascript stuff.
Callback prototype:
def callback(user): pass
Callbacks listening to this event must return a list of string.
Raised when a new mailbox alias is created.
Callback prototype:
def callback(user, mailbox_alias): pass
Raised when an existing mailbox alias is about to be deleted.
Callback prototype:
def callback(mailbox_alias): pass
Raised when an existing mailbox is modified.
Callback prototype:
def callback(newmailbox, oldmailbox): pass
Raised just before a password change action.
Callback prototype:
def callback(user): pass
Callbacks listening to this event must return a list containing either True or False. If at least one True is returned, the password change will be cancelled (ie. changing the password for this user is disabled).
Let extensions add custom content into the top bar.
Callback prototype:
def callback(user): pass
Callbacks listening to this event must return a list of string.
Raised when a user logs in.
Callback prototype:
def callback(request, username, password): pass