comparison MoinMoin/events/__init__.py @ 5280:d25574af97eb

event package: fix PEP8, c&p errors, trivial code changes
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 15 Nov 2009 10:23:51 +0100
parents 2aa43685e17b
children 50251583a7bb
comparison
equal deleted inserted replaced
5279:2aa43685e17b 5280:d25574af97eb
163 163
164 def __init__(self, request, jid): 164 def __init__(self, request, jid):
165 Event.__init__(self, request) 165 Event.__init__(self, request)
166 self.jid = jid 166 self.jid = jid
167 167
168
168 class JabberIDUnsetEvent(Event): 169 class JabberIDUnsetEvent(Event):
169 """ Sent when Jabber ID is no longer used 170 """ Sent when Jabber ID is no longer used
170 171
171 Obviously this will be usually sent along with JabberIDSetEvent, 172 Obviously this will be usually sent along with JabberIDSetEvent,
172 because we require user's jabber id to be unique by default. 173 because we require user's jabber id to be unique by default.
173 174
174 """ 175 """
175 def __init__(self, request, jid): 176 def __init__(self, request, jid):
176 Event.__init__(self, request) 177 Event.__init__(self, request)
177 self.jid = jid 178 self.jid = jid
179
178 180
179 class UserCreatedEvent(Event): 181 class UserCreatedEvent(Event):
180 """ Sent when a new user has been created """ 182 """ Sent when a new user has been created """
181 183
182 name = u"UserCreatedEvent" 184 name = u"UserCreatedEvent"
185 187
186 def __init__(self, request, user): 188 def __init__(self, request, user):
187 Event.__init__(self, request) 189 Event.__init__(self, request)
188 self.user = user 190 self.user = user
189 191
192
190 class PagePreSaveEvent(Event): 193 class PagePreSaveEvent(Event):
191 """ Event sent when a page is about to be saved 194 """ Event sent when a page is about to be saved
192 195
193 This can be used to abort a save, for instance, 196 This can be used to abort a save, for instance, if handler returns Abort.
194 if handler returns
195
196 """ 197 """
197 198
198 name = u"PagePreSaveEvent" 199 name = u"PagePreSaveEvent"
199 200
200 def __init__(self, request, page_editor, new_text): 201 def __init__(self, request, page_editor, new_text):
204 205
205 206
206 class EventResult: 207 class EventResult:
207 """ This is a base class for messages passed from event handlers """ 208 """ This is a base class for messages passed from event handlers """
208 pass 209 pass
210
209 211
210 class Abort(EventResult): 212 class Abort(EventResult):
211 """ Result returned if handler wants to abort operation that sent the event """ 213 """ Result returned if handler wants to abort operation that sent the event """
212 def __init__(self, reason): 214 def __init__(self, reason):
213 """ 215 """
217 219
218 220
219 def get_handlers(cfg): 221 def get_handlers(cfg):
220 """Create a list of available event handlers. 222 """Create a list of available event handlers.
221 223
222 Each handler is a handle() function defined in an plugin, 224 Each handler is a handle() function defined in a plugin,
223 pretty much like in case of actions. 225 pretty much like in case of actions.
224 226
225 TODO: maybe make it less dumb? ;-) 227 TODO: maybe make it less dumb? ;-)
226
227 """ 228 """
228 event_handlers = [] 229 event_handlers = []
229 names = wikiutil.getPlugins("events", cfg) 230 names = wikiutil.getPlugins("events", cfg)
230 231
231 for name in names: 232 for name in names:
260 if retval: 261 if retval:
261 msg.append(retval) 262 msg.append(retval)
262 263
263 return msg 264 return msg
264 265
266
265 def get_subscribable_events(): 267 def get_subscribable_events():
266 """Create and return a list of user-visible events 268 """Create and return a list of user-visible events
267 269
268 @return: A list of user-visible events described by dictionaries 270 @return: A list of user-visible events described by dictionaries
269 @rtype: dict 271 @rtype: dict
277 279
278 return subscribable_events 280 return subscribable_events
279 281
280 # Get rid of the dummy getText so that it doesn't get imported with * 282 # Get rid of the dummy getText so that it doesn't get imported with *
281 del _ 283 del _
284