annotate MoinMoin/events/__init__.py @ 2461:f456dc2048d1

i18n should now work. First step, no caching yet.
author Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
date Fri, 20 Jul 2007 00:24:21 +0200
parents 1007128cb089
children 3c5b329afe4b
rev   line source
2058
fb6f1de06be0 Start with a simplistic event handling system, which uses plugins in a way
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
fb6f1de06be0 Start with a simplistic event handling system, which uses plugins in a way
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents:
diff changeset
2 """
fb6f1de06be0 Start with a simplistic event handling system, which uses plugins in a way
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents:
diff changeset
3 MoinMoin - event (notification) framework
fb6f1de06be0 Start with a simplistic event handling system, which uses plugins in a way
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents:
diff changeset
4
fb6f1de06be0 Start with a simplistic event handling system, which uses plugins in a way
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents:
diff changeset
5 This code abstracts event handling in MoinMoin,
fb6f1de06be0 Start with a simplistic event handling system, which uses plugins in a way
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents:
diff changeset
6 currently for notifications. It implements the observer pattern.
fb6f1de06be0 Start with a simplistic event handling system, which uses plugins in a way
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents:
diff changeset
7
2064
5cc8f6714297 Add more event types. Return a list of messages generated by event handlers to caller.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2061
diff changeset
8 @copyright: 2007 by Karol Nowak <grywacz@gmail.com>
5cc8f6714297 Add more event types. Return a list of messages generated by event handlers to caller.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2061
diff changeset
9 @license: GNU GPL, see COPYING for details.
2058
fb6f1de06be0 Start with a simplistic event handling system, which uses plugins in a way
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents:
diff changeset
10 """
fb6f1de06be0 Start with a simplistic event handling system, which uses plugins in a way
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents:
diff changeset
11
2323
a43db0817020 Use stdlib's logging instead of prints.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2318
diff changeset
12 import logging
a43db0817020 Use stdlib's logging instead of prints.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2318
diff changeset
13
2058
fb6f1de06be0 Start with a simplistic event handling system, which uses plugins in a way
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents:
diff changeset
14 from MoinMoin import wikiutil
fb6f1de06be0 Start with a simplistic event handling system, which uses plugins in a way
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents:
diff changeset
15 from MoinMoin.util import pysupport
2073
afa784d8d58d Handle PluginErrors while loading event handlers gracefully.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2064
diff changeset
16 from MoinMoin.wikiutil import PluginAttributeError
2058
fb6f1de06be0 Start with a simplistic event handling system, which uses plugins in a way
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents:
diff changeset
17
fb6f1de06be0 Start with a simplistic event handling system, which uses plugins in a way
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents:
diff changeset
18 # Create a list of extension actions from the package directory
fb6f1de06be0 Start with a simplistic event handling system, which uses plugins in a way
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents:
diff changeset
19 modules = pysupport.getPackageModules(__file__)
fb6f1de06be0 Start with a simplistic event handling system, which uses plugins in a way
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents:
diff changeset
20
2323
a43db0817020 Use stdlib's logging instead of prints.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2318
diff changeset
21 # A module-wide Logger, don't use it from outside
a43db0817020 Use stdlib's logging instead of prints.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2318
diff changeset
22 logger = logging.getLogger("events")
a43db0817020 Use stdlib's logging instead of prints.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2318
diff changeset
23 logger.setLevel(logging.DEBUG)
a43db0817020 Use stdlib's logging instead of prints.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2318
diff changeset
24 logger.addHandler(logging.StreamHandler())
a43db0817020 Use stdlib's logging instead of prints.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2318
diff changeset
25
2086
c8bc6df45964 Formatting fixes according to PEP 8.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2077
diff changeset
26
2152
cf4c4a3d6085 Add a list of selectable events user wants to be notified about.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2145
diff changeset
27 class Event(object):
2058
fb6f1de06be0 Start with a simplistic event handling system, which uses plugins in a way
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents:
diff changeset
28 """A class handling information common to all events."""
2064
5cc8f6714297 Add more event types. Return a list of messages generated by event handlers to caller.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2061
diff changeset
29 def __init__(self, request):
5cc8f6714297 Add more event types. Return a list of messages generated by event handlers to caller.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2061
diff changeset
30 self.request = request
2086
c8bc6df45964 Formatting fixes according to PEP 8.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2077
diff changeset
31
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2152
diff changeset
32
2091
7af58454aafa Send an event when user changes her jabber id, force jid to be unique.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2086
diff changeset
33 class PageEvent(Event):
2061
7547652ffb6f Change Event -> Observable, add a helper PageEvent class.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2058
diff changeset
34 """An event related to a page change"""
2094
9ee68c8b409b Style fixes as suggested by Thomas.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2091
diff changeset
35 def __init__(self, request):
9ee68c8b409b Style fixes as suggested by Thomas.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2091
diff changeset
36 Event.__init__(self, request)
2086
c8bc6df45964 Formatting fixes according to PEP 8.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2077
diff changeset
37
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2152
diff changeset
38
2061
7547652ffb6f Change Event -> Observable, add a helper PageEvent class.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2058
diff changeset
39 class PageChangedEvent(PageEvent):
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2152
diff changeset
40
2152
cf4c4a3d6085 Add a list of selectable events user wants to be notified about.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2145
diff changeset
41 description = u"""Page has been modified (edit, creation, deletion)"""
cf4c4a3d6085 Add a list of selectable events user wants to be notified about.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2145
diff changeset
42 req_superuser = False
2337
1d85514968a2 Fix remaining excessive white space characters.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2336
diff changeset
43
2064
5cc8f6714297 Add more event types. Return a list of messages generated by event handlers to caller.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2061
diff changeset
44 def __init__(self, request, page, comment, trivial):
2094
9ee68c8b409b Style fixes as suggested by Thomas.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2091
diff changeset
45 PageEvent.__init__(self, request)
2064
5cc8f6714297 Add more event types. Return a list of messages generated by event handlers to caller.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2061
diff changeset
46 self.page = page
5cc8f6714297 Add more event types. Return a list of messages generated by event handlers to caller.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2061
diff changeset
47 self.comment = comment
5cc8f6714297 Add more event types. Return a list of messages generated by event handlers to caller.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2061
diff changeset
48 self.trivial = trivial
2086
c8bc6df45964 Formatting fixes according to PEP 8.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2077
diff changeset
49
2337
1d85514968a2 Fix remaining excessive white space characters.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2336
diff changeset
50
2061
7547652ffb6f Change Event -> Observable, add a helper PageEvent class.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2058
diff changeset
51 class PageRenamedEvent(PageEvent):
2337
1d85514968a2 Fix remaining excessive white space characters.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2336
diff changeset
52
2329
9a71ea0c941b Add support for PageRenamed event. Not tested yet.
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2323
diff changeset
53 description = u"""Page has been renamed"""
9a71ea0c941b Add support for PageRenamed event. Not tested yet.
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2323
diff changeset
54 req_superuser = False
2337
1d85514968a2 Fix remaining excessive white space characters.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2336
diff changeset
55
2461
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2415
diff changeset
56 def __init__(self, request, page, old_page, comment=""):
2329
9a71ea0c941b Add support for PageRenamed event. Not tested yet.
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2323
diff changeset
57 PageEvent.__init__(self, request)
9a71ea0c941b Add support for PageRenamed event. Not tested yet.
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2323
diff changeset
58 self.page = page
9a71ea0c941b Add support for PageRenamed event. Not tested yet.
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2323
diff changeset
59 self.old_page = old_page
9a71ea0c941b Add support for PageRenamed event. Not tested yet.
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2323
diff changeset
60 self.comment = comment
2109
b39379ab47d3 Send notifications when page is deleted + some small fixes.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2107
diff changeset
61
b39379ab47d3 Send notifications when page is deleted + some small fixes.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2107
diff changeset
62
2061
7547652ffb6f Change Event -> Observable, add a helper PageEvent class.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2058
diff changeset
63 class PageDeletedEvent(PageEvent):
2337
1d85514968a2 Fix remaining excessive white space characters.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2336
diff changeset
64
2152
cf4c4a3d6085 Add a list of selectable events user wants to be notified about.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2145
diff changeset
65 description = u"""Page has been deleted"""
cf4c4a3d6085 Add a list of selectable events user wants to be notified about.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2145
diff changeset
66 req_superuser = False
2337
1d85514968a2 Fix remaining excessive white space characters.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2336
diff changeset
67
2109
b39379ab47d3 Send notifications when page is deleted + some small fixes.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2107
diff changeset
68 def __init__(self, request, page, comment):
b39379ab47d3 Send notifications when page is deleted + some small fixes.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2107
diff changeset
69 PageEvent.__init__(self, request)
b39379ab47d3 Send notifications when page is deleted + some small fixes.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2107
diff changeset
70 self.page = page
b39379ab47d3 Send notifications when page is deleted + some small fixes.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2107
diff changeset
71 self.comment = comment
2106
1577663f6354 Notify when a new attachment is added to a page. s/JabberBot/jabberbot/.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2095
diff changeset
72
1577663f6354 Notify when a new attachment is added to a page. s/JabberBot/jabberbot/.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2095
diff changeset
73
2385
53fbdf5899ff Use the event handling framework to (re)generate xapian indexes.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2356
diff changeset
74 class PageCopiedEvent(PageEvent):
53fbdf5899ff Use the event handling framework to (re)generate xapian indexes.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2356
diff changeset
75
53fbdf5899ff Use the event handling framework to (re)generate xapian indexes.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2356
diff changeset
76 description = u"""Page has been copied"""
53fbdf5899ff Use the event handling framework to (re)generate xapian indexes.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2356
diff changeset
77 req_superuser = False
53fbdf5899ff Use the event handling framework to (re)generate xapian indexes.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2356
diff changeset
78
53fbdf5899ff Use the event handling framework to (re)generate xapian indexes.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2356
diff changeset
79 def __init__(self, request, page, old_page, comment):
53fbdf5899ff Use the event handling framework to (re)generate xapian indexes.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2356
diff changeset
80 PageEvent.__init__(self, request)
53fbdf5899ff Use the event handling framework to (re)generate xapian indexes.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2356
diff changeset
81 self.page = page
53fbdf5899ff Use the event handling framework to (re)generate xapian indexes.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2356
diff changeset
82 self.old_page = old_page
53fbdf5899ff Use the event handling framework to (re)generate xapian indexes.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2356
diff changeset
83 self.comment = comment
53fbdf5899ff Use the event handling framework to (re)generate xapian indexes.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2356
diff changeset
84
53fbdf5899ff Use the event handling framework to (re)generate xapian indexes.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2356
diff changeset
85
2064
5cc8f6714297 Add more event types. Return a list of messages generated by event handlers to caller.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2061
diff changeset
86 class FileAttachedEvent(PageEvent):
2337
1d85514968a2 Fix remaining excessive white space characters.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2336
diff changeset
87
2152
cf4c4a3d6085 Add a list of selectable events user wants to be notified about.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2145
diff changeset
88 description = u"""A new attachment has been added"""
cf4c4a3d6085 Add a list of selectable events user wants to be notified about.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2145
diff changeset
89 req_superuser = False
2337
1d85514968a2 Fix remaining excessive white space characters.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2336
diff changeset
90
2356
1d60f9aa07d1 Email notification about new attachments. Some i18n issues left to be fixed.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2337
diff changeset
91 def __init__(self, request, pagename, name, size):
2107
645bbc7fe2b5 Add forgotten invocation of parent constructor.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2106
diff changeset
92 PageEvent.__init__(self, request)
2106
1577663f6354 Notify when a new attachment is added to a page. s/JabberBot/jabberbot/.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2095
diff changeset
93 self.request = request
1577663f6354 Notify when a new attachment is added to a page. s/JabberBot/jabberbot/.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2095
diff changeset
94 self.pagename = pagename
2356
1d60f9aa07d1 Email notification about new attachments. Some i18n issues left to be fixed.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2337
diff changeset
95 self.name = name
2106
1577663f6354 Notify when a new attachment is added to a page. s/JabberBot/jabberbot/.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2095
diff changeset
96 self.size = size
2064
5cc8f6714297 Add more event types. Return a list of messages generated by event handlers to caller.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2061
diff changeset
97
2086
c8bc6df45964 Formatting fixes according to PEP 8.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2077
diff changeset
98
2064
5cc8f6714297 Add more event types. Return a list of messages generated by event handlers to caller.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2061
diff changeset
99 class PageRevertedEvent(PageEvent):
2337
1d85514968a2 Fix remaining excessive white space characters.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2336
diff changeset
100
2152
cf4c4a3d6085 Add a list of selectable events user wants to be notified about.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2145
diff changeset
101 description = u"""A page has been reverted to a previous state"""
cf4c4a3d6085 Add a list of selectable events user wants to be notified about.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2145
diff changeset
102 req_superuser = False
2337
1d85514968a2 Fix remaining excessive white space characters.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2336
diff changeset
103
2064
5cc8f6714297 Add more event types. Return a list of messages generated by event handlers to caller.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2061
diff changeset
104 def __init__(self, request, pagename, previous, current):
2094
9ee68c8b409b Style fixes as suggested by Thomas.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2091
diff changeset
105 PageEvent.__init__(self, request)
2064
5cc8f6714297 Add more event types. Return a list of messages generated by event handlers to caller.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2061
diff changeset
106 self.pagename = pagename
5cc8f6714297 Add more event types. Return a list of messages generated by event handlers to caller.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2061
diff changeset
107 self.previous = previous
2337
1d85514968a2 Fix remaining excessive white space characters.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2336
diff changeset
108 self.current = current
2064
5cc8f6714297 Add more event types. Return a list of messages generated by event handlers to caller.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2061
diff changeset
109
2086
c8bc6df45964 Formatting fixes according to PEP 8.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2077
diff changeset
110
2064
5cc8f6714297 Add more event types. Return a list of messages generated by event handlers to caller.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2061
diff changeset
111 class SubscribedToPageEvent(PageEvent):
2337
1d85514968a2 Fix remaining excessive white space characters.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2336
diff changeset
112
2152
cf4c4a3d6085 Add a list of selectable events user wants to be notified about.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2145
diff changeset
113 description = u"""An user has subscribed to a page"""
cf4c4a3d6085 Add a list of selectable events user wants to be notified about.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2145
diff changeset
114 req_superuser = True
2337
1d85514968a2 Fix remaining excessive white space characters.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2336
diff changeset
115
2064
5cc8f6714297 Add more event types. Return a list of messages generated by event handlers to caller.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2061
diff changeset
116 def __init__(self, request, pagename, username):
2337
1d85514968a2 Fix remaining excessive white space characters.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2336
diff changeset
117 PageEvent.__init__(self, request)
2064
5cc8f6714297 Add more event types. Return a list of messages generated by event handlers to caller.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2061
diff changeset
118 self.pagename = pagename
5cc8f6714297 Add more event types. Return a list of messages generated by event handlers to caller.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2061
diff changeset
119 self.username = username
5cc8f6714297 Add more event types. Return a list of messages generated by event handlers to caller.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2061
diff changeset
120
2086
c8bc6df45964 Formatting fixes according to PEP 8.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2077
diff changeset
121
2091
7af58454aafa Send an event when user changes her jabber id, force jid to be unique.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2086
diff changeset
122 class JabberIDSetEvent(Event):
7af58454aafa Send an event when user changes her jabber id, force jid to be unique.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2086
diff changeset
123 """ Sent when user changes her Jabber ID """
2337
1d85514968a2 Fix remaining excessive white space characters.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2336
diff changeset
124
2091
7af58454aafa Send an event when user changes her jabber id, force jid to be unique.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2086
diff changeset
125 def __init__(self, request, jid):
7af58454aafa Send an event when user changes her jabber id, force jid to be unique.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2086
diff changeset
126 Event.__init__(self, request)
7af58454aafa Send an event when user changes her jabber id, force jid to be unique.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2086
diff changeset
127 self.jid = jid
2337
1d85514968a2 Fix remaining excessive white space characters.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2336
diff changeset
128
2095
258d6e648eca Add a JabberIDUnsetEvent; make some private symbols internal in MoinMoin.events
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2094
diff changeset
129 class JabberIDUnsetEvent(Event):
258d6e648eca Add a JabberIDUnsetEvent; make some private symbols internal in MoinMoin.events
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2094
diff changeset
130 """ Sent when Jabber ID is no longer used
2337
1d85514968a2 Fix remaining excessive white space characters.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2336
diff changeset
131
2095
258d6e648eca Add a JabberIDUnsetEvent; make some private symbols internal in MoinMoin.events
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2094
diff changeset
132 Obviously this will be usually sent along with JabberIDSetEvent,
258d6e648eca Add a JabberIDUnsetEvent; make some private symbols internal in MoinMoin.events
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2094
diff changeset
133 because we require user's jabber id to be unique by default.
2337
1d85514968a2 Fix remaining excessive white space characters.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2336
diff changeset
134
2095
258d6e648eca Add a JabberIDUnsetEvent; make some private symbols internal in MoinMoin.events
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2094
diff changeset
135 """
258d6e648eca Add a JabberIDUnsetEvent; make some private symbols internal in MoinMoin.events
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2094
diff changeset
136 def __init__(self, request, jid):
258d6e648eca Add a JabberIDUnsetEvent; make some private symbols internal in MoinMoin.events
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2094
diff changeset
137 Event.__init__(self, request)
258d6e648eca Add a JabberIDUnsetEvent; make some private symbols internal in MoinMoin.events
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2094
diff changeset
138 self.jid = jid
2337
1d85514968a2 Fix remaining excessive white space characters.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2336
diff changeset
139
2145
f153b3155240 Send notifications about creation of users to Superusers with JID set.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2109
diff changeset
140 class UserCreatedEvent(Event):
f153b3155240 Send notifications about creation of users to Superusers with JID set.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2109
diff changeset
141 """ Sent when a new user has been created """
2337
1d85514968a2 Fix remaining excessive white space characters.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2336
diff changeset
142
2152
cf4c4a3d6085 Add a list of selectable events user wants to be notified about.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2145
diff changeset
143 description = u"""A new account has been created"""
cf4c4a3d6085 Add a list of selectable events user wants to be notified about.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2145
diff changeset
144 req_superuser = True
2337
1d85514968a2 Fix remaining excessive white space characters.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2336
diff changeset
145
2145
f153b3155240 Send notifications about creation of users to Superusers with JID set.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2109
diff changeset
146 def __init__(self, request, user):
f153b3155240 Send notifications about creation of users to Superusers with JID set.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2109
diff changeset
147 Event.__init__(self, request)
f153b3155240 Send notifications about creation of users to Superusers with JID set.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2109
diff changeset
148 self.user = user
2337
1d85514968a2 Fix remaining excessive white space characters.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2336
diff changeset
149
2396
cf85b6916d17 Add a PagePreSave event; abort page save if handlers return Abort.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2385
diff changeset
150 class PagePreSaveEvent(Event):
cf85b6916d17 Add a PagePreSave event; abort page save if handlers return Abort.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2385
diff changeset
151 """ Event sent when a page is about to be saved
cf85b6916d17 Add a PagePreSave event; abort page save if handlers return Abort.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2385
diff changeset
152
cf85b6916d17 Add a PagePreSave event; abort page save if handlers return Abort.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2385
diff changeset
153 This can be used to abort a save, for instance,
cf85b6916d17 Add a PagePreSave event; abort page save if handlers return Abort.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2385
diff changeset
154 if handler returns
cf85b6916d17 Add a PagePreSave event; abort page save if handlers return Abort.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2385
diff changeset
155
cf85b6916d17 Add a PagePreSave event; abort page save if handlers return Abort.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2385
diff changeset
156 """
cf85b6916d17 Add a PagePreSave event; abort page save if handlers return Abort.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2385
diff changeset
157 def __init__(self, request, page_editor, new_text):
cf85b6916d17 Add a PagePreSave event; abort page save if handlers return Abort.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2385
diff changeset
158 Event.__init__(self, request)
cf85b6916d17 Add a PagePreSave event; abort page save if handlers return Abort.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2385
diff changeset
159 self.page_editor = page_editor
cf85b6916d17 Add a PagePreSave event; abort page save if handlers return Abort.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2385
diff changeset
160 self.new_text = new_text
cf85b6916d17 Add a PagePreSave event; abort page save if handlers return Abort.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2385
diff changeset
161
cf85b6916d17 Add a PagePreSave event; abort page save if handlers return Abort.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2385
diff changeset
162
2318
062b76cf8d48 Introduce an base EventResult class for event handler return values.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2312
diff changeset
163 class EventResult:
062b76cf8d48 Introduce an base EventResult class for event handler return values.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2312
diff changeset
164 """ This is a base class for messages passed from event handlers """
062b76cf8d48 Introduce an base EventResult class for event handler return values.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2312
diff changeset
165 pass
2337
1d85514968a2 Fix remaining excessive white space characters.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2336
diff changeset
166
2396
cf85b6916d17 Add a PagePreSave event; abort page save if handlers return Abort.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2385
diff changeset
167 class Abort(EventResult):
cf85b6916d17 Add a PagePreSave event; abort page save if handlers return Abort.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2385
diff changeset
168 """ Result returned if handler wants to abort operation that sent the event """
cf85b6916d17 Add a PagePreSave event; abort page save if handlers return Abort.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2385
diff changeset
169 def __init__(self, reason):
cf85b6916d17 Add a PagePreSave event; abort page save if handlers return Abort.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2385
diff changeset
170 """
cf85b6916d17 Add a PagePreSave event; abort page save if handlers return Abort.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2385
diff changeset
171 @param reason: human-readable reason of failure
cf85b6916d17 Add a PagePreSave event; abort page save if handlers return Abort.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2385
diff changeset
172 """
cf85b6916d17 Add a PagePreSave event; abort page save if handlers return Abort.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2385
diff changeset
173 self.reason = reason
2415
1007128cb089 Whitespace/pep8 fixes.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2396
diff changeset
174
2396
cf85b6916d17 Add a PagePreSave event; abort page save if handlers return Abort.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2385
diff changeset
175
2307
fe37834deb3d Move a list of event handlers and subscribable events to config.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2152
diff changeset
176 def get_handlers(cfg):
2058
fb6f1de06be0 Start with a simplistic event handling system, which uses plugins in a way
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents:
diff changeset
177 """Create a list of available event handlers.
2337
1d85514968a2 Fix remaining excessive white space characters.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2336
diff changeset
178
2058
fb6f1de06be0 Start with a simplistic event handling system, which uses plugins in a way
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents:
diff changeset
179 Each handler is a handle() function defined in an plugin,
fb6f1de06be0 Start with a simplistic event handling system, which uses plugins in a way
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents:
diff changeset
180 pretty much like in case of actions.
2337
1d85514968a2 Fix remaining excessive white space characters.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2336
diff changeset
181
2307
fe37834deb3d Move a list of event handlers and subscribable events to config.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2152
diff changeset
182 TODO: maybe make it less dumb? ;-)
2337
1d85514968a2 Fix remaining excessive white space characters.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2336
diff changeset
183
2307
fe37834deb3d Move a list of event handlers and subscribable events to config.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2152
diff changeset
184 """
fe37834deb3d Move a list of event handlers and subscribable events to config.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2152
diff changeset
185 event_handlers = []
2058
fb6f1de06be0 Start with a simplistic event handling system, which uses plugins in a way
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents:
diff changeset
186 names = wikiutil.getPlugins("events", cfg)
fb6f1de06be0 Start with a simplistic event handling system, which uses plugins in a way
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents:
diff changeset
187
fb6f1de06be0 Start with a simplistic event handling system, which uses plugins in a way
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents:
diff changeset
188 for name in names:
2073
afa784d8d58d Handle PluginErrors while loading event handlers gracefully.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2064
diff changeset
189 try:
afa784d8d58d Handle PluginErrors while loading event handlers gracefully.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2064
diff changeset
190 handler = wikiutil.importPlugin(cfg, "events", name, "handle")
afa784d8d58d Handle PluginErrors while loading event handlers gracefully.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2064
diff changeset
191 except PluginAttributeError:
afa784d8d58d Handle PluginErrors while loading event handlers gracefully.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2064
diff changeset
192 handler = None
2337
1d85514968a2 Fix remaining excessive white space characters.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2336
diff changeset
193
2058
fb6f1de06be0 Start with a simplistic event handling system, which uses plugins in a way
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents:
diff changeset
194 if handler is not None:
2307
fe37834deb3d Move a list of event handlers and subscribable events to config.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2152
diff changeset
195 event_handlers.append(handler)
2337
1d85514968a2 Fix remaining excessive white space characters.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2336
diff changeset
196
2307
fe37834deb3d Move a list of event handlers and subscribable events to config.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2152
diff changeset
197 return event_handlers
2058
fb6f1de06be0 Start with a simplistic event handling system, which uses plugins in a way
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents:
diff changeset
198
2086
c8bc6df45964 Formatting fixes according to PEP 8.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2077
diff changeset
199
2058
fb6f1de06be0 Start with a simplistic event handling system, which uses plugins in a way
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents:
diff changeset
200 def send_event(event):
2312
a85d51778eda Remove a forgotten line, improve comment.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2307
diff changeset
201 """Function called from outside to process an event
2337
1d85514968a2 Fix remaining excessive white space characters.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2336
diff changeset
202
2312
a85d51778eda Remove a forgotten line, improve comment.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2307
diff changeset
203 @return: a list of messages returned by handlers
a85d51778eda Remove a forgotten line, improve comment.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2307
diff changeset
204 @rtype: list
a85d51778eda Remove a forgotten line, improve comment.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2307
diff changeset
205 """
2337
1d85514968a2 Fix remaining excessive white space characters.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2336
diff changeset
206
2064
5cc8f6714297 Add more event types. Return a list of messages generated by event handlers to caller.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2061
diff changeset
207 # A list of messages generated by event handlers, passed back to caller
5cc8f6714297 Add more event types. Return a list of messages generated by event handlers to caller.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2061
diff changeset
208 msg = []
2307
fe37834deb3d Move a list of event handlers and subscribable events to config.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2152
diff changeset
209 cfg = event.request.cfg
2337
1d85514968a2 Fix remaining excessive white space characters.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2336
diff changeset
210
2058
fb6f1de06be0 Start with a simplistic event handling system, which uses plugins in a way
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents:
diff changeset
211 # Try to handle the event with each available handler (for now)
2307
fe37834deb3d Move a list of event handlers and subscribable events to config.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2152
diff changeset
212 for handle in cfg.event_handlers:
2064
5cc8f6714297 Add more event types. Return a list of messages generated by event handlers to caller.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2061
diff changeset
213 retval = handle(event)
2385
53fbdf5899ff Use the event handling framework to (re)generate xapian indexes.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2356
diff changeset
214
53fbdf5899ff Use the event handling framework to (re)generate xapian indexes.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2356
diff changeset
215 assert retval is None or isinstance(retval, EventResult)
53fbdf5899ff Use the event handling framework to (re)generate xapian indexes.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2356
diff changeset
216
2318
062b76cf8d48 Introduce an base EventResult class for event handler return values.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2312
diff changeset
217 if retval:
2064
5cc8f6714297 Add more event types. Return a list of messages generated by event handlers to caller.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2061
diff changeset
218 msg.append(retval)
2337
1d85514968a2 Fix remaining excessive white space characters.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2336
diff changeset
219
2076
0128bbaf0172 Add newlines at the end of files, fix some overzealous deletion.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2073
diff changeset
220 return msg
2152
cf4c4a3d6085 Add a list of selectable events user wants to be notified about.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2145
diff changeset
221
cf4c4a3d6085 Add a list of selectable events user wants to be notified about.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2145
diff changeset
222 def get_subscribable_events():
cf4c4a3d6085 Add a list of selectable events user wants to be notified about.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2145
diff changeset
223 """Create and return a list of user-visible events
2337
1d85514968a2 Fix remaining excessive white space characters.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2336
diff changeset
224
2152
cf4c4a3d6085 Add a list of selectable events user wants to be notified about.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2145
diff changeset
225 @return: A list of user-visible events described by dictionaries
cf4c4a3d6085 Add a list of selectable events user wants to be notified about.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2145
diff changeset
226 @rtype: dict
cf4c4a3d6085 Add a list of selectable events user wants to be notified about.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2145
diff changeset
227 """
cf4c4a3d6085 Add a list of selectable events user wants to be notified about.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2145
diff changeset
228 defs = globals()
2337
1d85514968a2 Fix remaining excessive white space characters.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2336
diff changeset
229 subscribable_events = {}
1d85514968a2 Fix remaining excessive white space characters.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2336
diff changeset
230
2307
fe37834deb3d Move a list of event handlers and subscribable events to config.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2152
diff changeset
231 for ev in defs.values():
fe37834deb3d Move a list of event handlers and subscribable events to config.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2152
diff changeset
232 if type(ev) is type and issubclass(ev, Event) and ev.__dict__.has_key("description"):
fe37834deb3d Move a list of event handlers and subscribable events to config.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2152
diff changeset
233 subscribable_events[ev.__name__] = {'desc': ev.description,
fe37834deb3d Move a list of event handlers and subscribable events to config.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2152
diff changeset
234 'superuser': ev.req_superuser}
fe37834deb3d Move a list of event handlers and subscribable events to config.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2152
diff changeset
235 return subscribable_events