changeset 2495:b9e0a8a1f14c

Merge devel.
author Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
date Sun, 22 Jul 2007 04:17:31 +0200
parents fabbb4dbd99e (current diff) 7283062fce1a (diff)
children d9e112066a9e
files
diffstat 8 files changed, 44 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/_tests/test_PageEditor.py	Sun Jul 22 03:27:45 2007 +0200
+++ b/MoinMoin/_tests/test_PageEditor.py	Sun Jul 22 04:17:31 2007 +0200
@@ -171,34 +171,34 @@
 
 
 class TestSave:
-    
+
     def setup_method(self, method):
         self.old_handlers = self.request.cfg.event_handlers
         gain_superuser_rights(self.request)
-        
+
     def teardown_method(self, method):
         self.request.cfg.event_handlers = self.old_handlers
-        
+
     def testSaveAbort(self):
         """Test if saveText() is interrupted if PagePreSave event handler returns Abort"""
-    
+
         def handler(event):
             from MoinMoin.events import Abort
             return Abort("This is just a test")
-    
+
         pagename = u'AutoCreatedMoinMoinTemporaryTestPageFortestSave'
         testtext = u'ThisIsSomeStupidTestPageText!'
 
         self.request.cfg.event_handlers = [handler]
-        
+
         page = Page(self.request, pagename)
         if page.exists():
             deleter = PageEditor(self.request, pagename)
             deleter.deletePage()
-    
+
         editor = PageEditor(self.request, pagename)
         editor.saveText(testtext, 0)
-    
+
         print "PageEditor can't save a page if Abort is returned from PreSave event handlers"
         page = Page(self.request, pagename)
         assert page.body != testtext
--- a/MoinMoin/action/AttachFile.py	Sun Jul 22 03:27:45 2007 +0200
+++ b/MoinMoin/action/AttachFile.py	Sun Jul 22 04:17:31 2007 +0200
@@ -27,6 +27,7 @@
 """
 
 import os, time, zipfile, mimetypes
+
 from MoinMoin import config, wikiutil, packages
 from MoinMoin.Page import Page
 from MoinMoin.util import filesys, timefuncs
@@ -223,22 +224,7 @@
         _addLogEntry(request, 'ATTNEW', pagename, target)
 
         event = FileAttachedEvent(request, pagename, target, len(filecontent))
-        results = send_event(event)
-
-        recipients = []
-        for result in results:
-            if isinstance(results, notification.Success):
-                recipients.append(result.recipient)
-
-        if recipients:
-            info = _("Notifications sent to:")
-            msg = msg + "<p>%s %s</p>" % (info, ",".join(recipients))
-
-        if request.cfg.xapian_search:
-            from MoinMoin.search.Xapian import Index
-            index = Index(request)
-            if index.exists():
-                index.update_page(pagename)
+        send_event(event)
 
         return target
 
--- a/MoinMoin/action/newaccount.py	Sun Jul 22 03:27:45 2007 +0200
+++ b/MoinMoin/action/newaccount.py	Sun Jul 22 04:17:31 2007 +0200
@@ -83,9 +83,6 @@
     # save data
     theuser.save()
 
-    user_created = events.UserCreatedEvent(request, theuser)
-    events.send_event(user_created)
-
     if form.has_key('create_and_mail'):
         theuser.mailAccountData()
 
--- a/MoinMoin/config/multiconfig.py	Sun Jul 22 03:27:45 2007 +0200
+++ b/MoinMoin/config/multiconfig.py	Sun Jul 22 04:17:31 2007 +0200
@@ -445,6 +445,11 @@
                      some string with an error msg, if the password is problematic.
         """
         try:
+            set
+        except:
+            from sets import Set as set
+
+        try:
             # in any case, do a very simple built-in check to avoid the worst passwords
             if len(password) < 6:
                 raise ValueError("Password too short.")
--- a/MoinMoin/events/__init__.py	Sun Jul 22 03:27:45 2007 +0200
+++ b/MoinMoin/events/__init__.py	Sun Jul 22 04:17:31 2007 +0200
@@ -27,6 +27,7 @@
 # so that they get into .po files
 _ = lambda x: x
 
+
 class Event(object):
     """A class handling information common to all events."""
     def __init__(self, request):
--- a/MoinMoin/events/jabbernotify.py	Sun Jul 22 03:27:45 2007 +0200
+++ b/MoinMoin/events/jabbernotify.py	Sun Jul 22 04:17:31 2007 +0200
@@ -146,7 +146,7 @@
         if usr.isSuperUser() and usr.jid and event_name in usr.jabber_subscribed_events:
             jids.append(usr.jid)
 
-    send_notification(event.request, jids, msg % (event.user.name, email), data['subject'])
+    send_notification(event.request, jids, data['body'], data['subject'])
 
 
 def page_change(type, request, page, subscribers, **kwargs):
--- a/MoinMoin/events/xapian_index.py	Sun Jul 22 03:27:45 2007 +0200
+++ b/MoinMoin/events/xapian_index.py	Sun Jul 22 04:17:31 2007 +0200
@@ -1,10 +1,12 @@
 # -*- coding: iso-8859-1 -*-
 """
     MoinMoin - (re)building of Xapian indices
+
+    @copyright: 2007 MoinMoin:KarolNowak
+    @license: GNU GPL, see COPYING for details.
 """
 import MoinMoin.events as ev
 
-
 def handle_renamed(event):
     """Updates Xapian index when a page changes its name"""
 
@@ -46,10 +48,22 @@
 
 def handle_deleted(event):
     """Updates Xapian index when a page is deleted"""
-    event = ev.PageChangedEvent(event.request, event.page, event.comment, False)
+    event = ev.PageChangedEvent(event.request, event.page, event.comment)
     handle_changed(event, deleted=True)
 
 
+def handle_attached(event):
+    """Updates Xapian index when a new attachment is added"""
+
+    request = event.request
+
+    if request.cfg.xapian_search:
+        from MoinMoin.search.Xapian import Index
+        index = Index(request)
+        if index.exists():
+            index.update_page(request.page.page_name)
+
+
 def handle(event):
     if isinstance(event, ev.PageRenamedEvent):
         handle_renamed(event)
@@ -59,3 +73,5 @@
         handle_changed(event)
     elif isinstance(event, ev.PageDeletedEvent):
         handle_deleted(event)
+    elif isinstance(event, ev.FileAttachedEvent):
+        handle_attached(event)
--- a/MoinMoin/user.py	Sun Jul 22 03:27:45 2007 +0200
+++ b/MoinMoin/user.py	Sun Jul 22 04:17:31 2007 +0200
@@ -24,7 +24,7 @@
 
 import os, time, sha, codecs
 
-from MoinMoin import config, caching, wikiutil, i18n
+from MoinMoin import config, caching, wikiutil, i18n, events
 from MoinMoin.util import timefuncs, filesys
 
 
@@ -325,6 +325,7 @@
         #self.edit_cols = 80
         self.tz_offset = int(float(self._cfg.tz_offset) * 3600)
         self.language = ""
+        self.loaded = False
         self.date_fmt = ""
         self.datetime_fmt = ""
         self.quicklinks = self._cfg.quicklinks_default
@@ -492,6 +493,9 @@
         if not self.disabled:
             self.valid = 1
 
+        # Mark this user as loaded from disk, so UserCreatedEvent is not sent
+        self.loaded = True
+
         # If user data has been changed, save fixed user data.
         if changed:
             self.save()
@@ -614,6 +618,10 @@
         if not self.disabled:
             self.valid = 1
 
+        if not self.loaded:
+            event = events.UserCreatedEvent(self._request, self)
+            events.send_event(event)
+
     # -----------------------------------------------------------------
     # Time and date formatting