annotate MoinMoin/events/__init__.py @ 2467:31b3d03bd1ea

s/An/A/
author Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
date Fri, 20 Jul 2007 01:58:03 +0200
parents 3c5b329afe4b
children 663867be4afc
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
2464
3c5b329afe4b Add a pseudo-getText function to that strings can get into .po files
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2461
diff changeset
26 # Dummy pseudo-getText function used in event descriptions,
3c5b329afe4b Add a pseudo-getText function to that strings can get into .po files
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2461
diff changeset
27 # so that they get into .po files
3c5b329afe4b Add a pseudo-getText function to that strings can get into .po files
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2461
diff changeset
28 _ = lambda x: x
2086
c8bc6df45964 Formatting fixes according to PEP 8.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2077
diff changeset
29
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
30 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
31 """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
32 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
33 self.request = request
2086
c8bc6df45964 Formatting fixes according to PEP 8.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2077
diff changeset
34
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2152
diff changeset
35
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
36 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
37 """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
38 def __init__(self, request):
9ee68c8b409b Style fixes as suggested by Thomas.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2091
diff changeset
39 Event.__init__(self, request)
2086
c8bc6df45964 Formatting fixes according to PEP 8.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2077
diff changeset
40
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2152
diff changeset
41
2061
7547652ffb6f Change Event -> Observable, add a helper PageEvent class.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2058
diff changeset
42 class PageChangedEvent(PageEvent):
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2152
diff changeset
43
2464
3c5b329afe4b Add a pseudo-getText function to that strings can get into .po files
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2461
diff changeset
44 description = _(u"""Page has been modified (edit, creation, deletion)""")
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
45 req_superuser = False
2337
1d85514968a2 Fix remaining excessive white space characters.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2336
diff changeset
46
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
47 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
48 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
49 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
50 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
51 self.trivial = trivial
2086
c8bc6df45964 Formatting fixes according to PEP 8.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2077
diff changeset
52
2337
1d85514968a2 Fix remaining excessive white space characters.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2336
diff changeset
53
2061
7547652ffb6f Change Event -> Observable, add a helper PageEvent class.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2058
diff changeset
54 class PageRenamedEvent(PageEvent):
2337
1d85514968a2 Fix remaining excessive white space characters.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2336
diff changeset
55
2464
3c5b329afe4b Add a pseudo-getText function to that strings can get into .po files
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2461
diff changeset
56 description = _(u"""Page has been renamed""")
2329
9a71ea0c941b Add support for PageRenamed event. Not tested yet.
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2323
diff changeset
57 req_superuser = False
2337
1d85514968a2 Fix remaining excessive white space characters.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2336
diff changeset
58
2461
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2399
diff changeset
59 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
60 PageEvent.__init__(self, request)
9a71ea0c941b Add support for PageRenamed event. Not tested yet.
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2323
diff changeset
61 self.page = page
9a71ea0c941b Add support for PageRenamed event. Not tested yet.
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2323
diff changeset
62 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
63 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
64
b39379ab47d3 Send notifications when page is deleted + some small fixes.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2107
diff changeset
65
2061
7547652ffb6f Change Event -> Observable, add a helper PageEvent class.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2058
diff changeset
66 class PageDeletedEvent(PageEvent):
2337
1d85514968a2 Fix remaining excessive white space characters.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2336
diff changeset
67
2464
3c5b329afe4b Add a pseudo-getText function to that strings can get into .po files
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2461
diff changeset
68 description = _(u"""Page has been deleted""")
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
69 req_superuser = False
2337
1d85514968a2 Fix remaining excessive white space characters.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2336
diff changeset
70
2109
b39379ab47d3 Send notifications when page is deleted + some small fixes.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2107
diff changeset
71 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
72 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
73 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
74 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
75
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
76
2385
53fbdf5899ff Use the event handling framework to (re)generate xapian indexes.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2356
diff changeset
77 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
78
2464
3c5b329afe4b Add a pseudo-getText function to that strings can get into .po files
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2461
diff changeset
79 description = _(u"""Page has been copied""")
2385
53fbdf5899ff Use the event handling framework to (re)generate xapian indexes.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2356
diff changeset
80 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
81
53fbdf5899ff Use the event handling framework to (re)generate xapian indexes.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2356
diff changeset
82 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
83 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
84 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
85 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
86 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
87
53fbdf5899ff Use the event handling framework to (re)generate xapian indexes.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2356
diff changeset
88
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
89 class FileAttachedEvent(PageEvent):
2337
1d85514968a2 Fix remaining excessive white space characters.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2336
diff changeset
90
2464
3c5b329afe4b Add a pseudo-getText function to that strings can get into .po files
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2461
diff changeset
91 description = _(u"""A new attachment has been added""")
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
92 req_superuser = False
2337
1d85514968a2 Fix remaining excessive white space characters.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2336
diff changeset
93
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
94 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
95 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
96 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
97 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
98 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
99 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
100
2086
c8bc6df45964 Formatting fixes according to PEP 8.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2077
diff changeset
101
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
102 class PageRevertedEvent(PageEvent):
2337
1d85514968a2 Fix remaining excessive white space characters.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2336
diff changeset
103
2464
3c5b329afe4b Add a pseudo-getText function to that strings can get into .po files
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2461
diff changeset
104 description = _(u"""A page has been reverted to a previous state""")
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
105 req_superuser = False
2337
1d85514968a2 Fix remaining excessive white space characters.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2336
diff changeset
106
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
107 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
108 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
109 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
110 self.previous = previous
2337
1d85514968a2 Fix remaining excessive white space characters.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2336
diff changeset
111 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
112
2086
c8bc6df45964 Formatting fixes according to PEP 8.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2077
diff changeset
113
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
114 class SubscribedToPageEvent(PageEvent):
2337
1d85514968a2 Fix remaining excessive white space characters.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2336
diff changeset
115
2467
31b3d03bd1ea s/An/A/
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2464
diff changeset
116 description = _(u"""A user has subscribed to a page""")
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
117 req_superuser = True
2337
1d85514968a2 Fix remaining excessive white space characters.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2336
diff changeset
118
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
119 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
120 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
121 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
122 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
123
2086
c8bc6df45964 Formatting fixes according to PEP 8.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2077
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 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
126 """ 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
127
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
128 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
129 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
130 self.jid = jid
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 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
133 """ 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
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 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
136 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
137
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
138 """
258d6e648eca Add a JabberIDUnsetEvent; make some private symbols internal in MoinMoin.events
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2094
diff changeset
139 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
140 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
141 self.jid = jid
2337
1d85514968a2 Fix remaining excessive white space characters.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2336
diff changeset
142
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
143 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
144 """ 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
145
2464
3c5b329afe4b Add a pseudo-getText function to that strings can get into .po files
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2461
diff changeset
146 description = _(u"""A new account has been created""")
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
147 req_superuser = True
2337
1d85514968a2 Fix remaining excessive white space characters.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2336
diff changeset
148
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
149 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
150 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
151 self.user = user
2337
1d85514968a2 Fix remaining excessive white space characters.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2336
diff changeset
152
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
153 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
154 """ 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
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 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
157 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
158
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 """
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 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
161 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
162 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
163 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
164
cf85b6916d17 Add a PagePreSave event; abort page save if handlers return Abort.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2385
diff changeset
165
2318
062b76cf8d48 Introduce an base EventResult class for event handler return values.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2312
diff changeset
166 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
167 """ 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
168 pass
2337
1d85514968a2 Fix remaining excessive white space characters.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2336
diff changeset
169
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
170 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
171 """ 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
172 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
173 """
cf85b6916d17 Add a PagePreSave event; abort page save if handlers return Abort.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2385
diff changeset
174 @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
175 """
cf85b6916d17 Add a PagePreSave event; abort page save if handlers return Abort.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2385
diff changeset
176 self.reason = reason
2399
245181ec9fe2 Whitespace fixes.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2396
diff changeset
177
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
178
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
179 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
180 """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
181
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
182 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
183 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
184
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
185 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
186
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
187 """
fe37834deb3d Move a list of event handlers and subscribable events to config.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2152
diff changeset
188 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
189 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
190
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
191 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
192 try:
afa784d8d58d Handle PluginErrors while loading event handlers gracefully.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2064
diff changeset
193 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
194 except PluginAttributeError:
afa784d8d58d Handle PluginErrors while loading event handlers gracefully.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2064
diff changeset
195 handler = None
2337
1d85514968a2 Fix remaining excessive white space characters.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2336
diff changeset
196
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
197 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
198 event_handlers.append(handler)
2337
1d85514968a2 Fix remaining excessive white space characters.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2336
diff changeset
199
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
200 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
201
2086
c8bc6df45964 Formatting fixes according to PEP 8.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2077
diff changeset
202
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
203 def send_event(event):
2312
a85d51778eda Remove a forgotten line, improve comment.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2307
diff changeset
204 """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
205
2312
a85d51778eda Remove a forgotten line, improve comment.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2307
diff changeset
206 @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
207 @rtype: list
a85d51778eda Remove a forgotten line, improve comment.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2307
diff changeset
208 """
2337
1d85514968a2 Fix remaining excessive white space characters.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2336
diff changeset
209
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
210 # 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
211 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
212 cfg = event.request.cfg
2337
1d85514968a2 Fix remaining excessive white space characters.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2336
diff changeset
213
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
214 # 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
215 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
216 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
217
53fbdf5899ff Use the event handling framework to (re)generate xapian indexes.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2356
diff changeset
218 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
219
2318
062b76cf8d48 Introduce an base EventResult class for event handler return values.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2312
diff changeset
220 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
221 msg.append(retval)
2337
1d85514968a2 Fix remaining excessive white space characters.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2336
diff changeset
222
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
223 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
224
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 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
226 """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
227
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
228 @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
229 @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
230 """
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
231 defs = globals()
2337
1d85514968a2 Fix remaining excessive white space characters.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2336
diff changeset
232 subscribable_events = {}
1d85514968a2 Fix remaining excessive white space characters.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2336
diff changeset
233
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
234 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
235 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
236 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
237 '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
238 return subscribable_events
2464
3c5b329afe4b Add a pseudo-getText function to that strings can get into .po files
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2461
diff changeset
239
3c5b329afe4b Add a pseudo-getText function to that strings can get into .po files
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2461
diff changeset
240 # Get rid of the dummy getText so that it doesn't get imported with *
3c5b329afe4b Add a pseudo-getText function to that strings can get into .po files
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2461
diff changeset
241 del _