changeset 2633:f42fb1ae0a38

Fixes to the Event.name commit.
author Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
date Thu, 26 Jul 2007 04:05:21 +0200
parents 584e1714aa05
children 53a79ea2ad93
files MoinMoin/events/__init__.py MoinMoin/events/emailnotify.py MoinMoin/events/notification.py
diffstat 3 files changed, 14 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/events/__init__.py	Tue Jul 24 02:11:32 2007 +0200
+++ b/MoinMoin/events/__init__.py	Thu Jul 26 04:05:21 2007 +0200
@@ -30,12 +30,19 @@
 
 class Event(object):
     """A class handling information common to all events."""
+
+    # NOTE: each Event subclass must have a unique name attribute
+    name = u"Event"
+
     def __init__(self, request):
         self.request = request
 
 
 class PageEvent(Event):
     """An event related to a page change"""
+
+    name = u"PageEvent"
+
     def __init__(self, request):
         Event.__init__(self, request)
 
@@ -177,6 +184,9 @@
     if handler returns
 
     """
+
+    name = u"PagePreSaveEvent"
+
     def __init__(self, request, page_editor, new_text):
         Event.__init__(self, request)
         self.page_editor = page_editor
--- a/MoinMoin/events/emailnotify.py	Tue Jul 24 02:11:32 2007 +0200
+++ b/MoinMoin/events/emailnotify.py	Thu Jul 26 04:05:21 2007 +0200
@@ -80,7 +80,7 @@
         # send email to all subscribers
         for lang in subscribers:
             users = [u for u in subscribers[lang]
-                     if ev.PageChangedEvent.__name__ in u.email_subscribed_events]
+                     if ev.PageChangedEvent.name in u.email_subscribed_events]
             emails = [u.email for u in users]
             names = [u.name for u in users]
             data = prep_page_changed_mail(request, page, comment, lang, revisions, trivial)
@@ -98,7 +98,7 @@
     emails = []
     _ = event.request.getText
     user_ids = getUserList(event.request)
-    event_name = event.__class__.__name__
+    event_name = event.name
 
     from_address = event.request.cfg.mail_from
     email = event.user.email or u"NOT SET"
@@ -122,7 +122,7 @@
 
     names = set()
     _ = event.request.getText
-    event_name = event.__class__.__name__
+    event_name = event.name
     from_address = event.request.cfg.mail_from
     request = event.request
     page = Page(request, event.pagename)
--- a/MoinMoin/events/notification.py	Tue Jul 24 02:11:32 2007 +0200
+++ b/MoinMoin/events/notification.py	Thu Jul 26 04:05:21 2007 +0200
@@ -185,7 +185,7 @@
     @type subscribers: dict
 
     """
-    event_name = event.__class__.__name__
+    event_name = event.name
 
     # Filter the list by removing users who don't want to receive
     # notifications about this type of event