comparison MoinMoin/events/__init__.py @ 2086:c8bc6df45964

Formatting fixes according to PEP 8.
author Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
date Sun, 03 Jun 2007 16:36:04 +0200
parents 636e646f909b
children 7af58454aafa
comparison
equal deleted inserted replaced
2085:d72f126157f7 2086:c8bc6df45964
11 11
12 from MoinMoin import wikiutil 12 from MoinMoin import wikiutil
13 from MoinMoin.util import pysupport 13 from MoinMoin.util import pysupport
14 from MoinMoin.wikiutil import PluginAttributeError 14 from MoinMoin.wikiutil import PluginAttributeError
15 15
16
16 # A list of available event handlers 17 # A list of available event handlers
17 event_handlers = None 18 event_handlers = None
18 19
19 # Create a list of extension actions from the package directory 20 # Create a list of extension actions from the package directory
20 modules = pysupport.getPackageModules(__file__) 21 modules = pysupport.getPackageModules(__file__)
21 22
23
22 class Observable: 24 class Observable:
23 """A class handling information common to all events.""" 25 """A class handling information common to all events."""
24 26
25 def __init__(self, request): 27 def __init__(self, request):
26 self.request = request 28 self.request = request
29
27 30
28 class PageEvent(Observable): 31 class PageEvent(Observable):
29 """An event related to a page change""" 32 """An event related to a page change"""
33
30 34
31 class PageChangedEvent(PageEvent): 35 class PageChangedEvent(PageEvent):
32 def __init__(self, request, page, comment, trivial): 36 def __init__(self, request, page, comment, trivial):
33 Observable.__init__(self, request) 37 Observable.__init__(self, request)
34 self.page = page 38 self.page = page
35 self.comment = comment 39 self.comment = comment
36 self.trivial = trivial 40 self.trivial = trivial
41
37 42
38 class PageRenamedEvent(PageEvent): 43 class PageRenamedEvent(PageEvent):
39 pass 44 pass
40 class PageDeletedEvent(PageEvent): 45 class PageDeletedEvent(PageEvent):
41 pass 46 pass
42 class FileAttachedEvent(PageEvent): 47 class FileAttachedEvent(PageEvent):
43 pass 48 pass
44 49
50
45 class PageRevertedEvent(PageEvent): 51 class PageRevertedEvent(PageEvent):
46 def __init__(self, request, pagename, previous, current): 52 def __init__(self, request, pagename, previous, current):
47 Observable.__init__(self, request) 53 Observable.__init__(self, request)
48 self.pagename = pagename 54 self.pagename = pagename
49 self.previous = previous 55 self.previous = previous
50 self.current = current 56 self.current = current
51 57
58
52 class SubscribedToPageEvent(PageEvent): 59 class SubscribedToPageEvent(PageEvent):
53 def __init__(self, request, pagename, username): 60 def __init__(self, request, pagename, username):
54 Observable.__init__(self, request) 61 Observable.__init__(self, request)
55 self.pagename = pagename 62 self.pagename = pagename
56 self.username = username 63 self.username = username
64
57 65
58 def register_handlers(cfg): 66 def register_handlers(cfg):
59 """Create a list of available event handlers. 67 """Create a list of available event handlers.
60 68
61 Each handler is a handle() function defined in an plugin, 69 Each handler is a handle() function defined in an plugin,
75 handler = None 83 handler = None
76 84
77 if handler is not None: 85 if handler is not None:
78 event_handlers.append(handler) 86 event_handlers.append(handler)
79 87
88
80 def send_event(event): 89 def send_event(event):
81 """Function called from outside to process an event""" 90 """Function called from outside to process an event"""
82 91
83 # A list of messages generated by event handlers, passed back to caller 92 # A list of messages generated by event handlers, passed back to caller
84 msg = [] 93 msg = []