23
23
Every extension has to define a list of accessible methods as
24
24
'PUBLIC_METHODS'. The constructor of an Extension object takes the
25
engine object it extends as the only argument
25
engine object it extends as the only argument.
27
In addition each extension has a set of hooks to control how events are
28
inserted and retrieved from the log. These hooks can either block the
29
event completely, modify it, or add additional metadata to it.
27
31
PUBLIC_METHODS = None
29
33
def __init__(self, engine):
30
34
self.engine = engine
36
def filter_insert_event(self, event):
38
Hook applied to all events before they are inserted into the
39
log. The returned event is progressively passed through all
40
extensions before the final result is inserted.
42
To block an event completely simply return :const:`None`.
43
The event may also be modified or completely substituted for
46
The default implementation of this method simply returns the
49
:param event: An :class:`Event <zeitgeist.datamodel.Event>`
51
:returns: The filtered event instance to insert into the log
55
def filter_get_event(self, event):
57
Hook applied to all events before they are returned to a client.
58
The event returned from this method is progressively passed
59
through all extensions before they final result is returned to
62
To prevent an event from ever leaving the server process simply
63
return :const:`None`. The event may also be changed in place
64
or fully substituted for another event.
66
The default implementation of this method simply returns the
69
:param event: An :class:`Event <zeitgeist.datamodel.Event>`
71
:returns: The filtered event instance as the client
33
76
class ExtensionsCollection(object):
34
77
""" Collection to manage all extensions """