changeset 2490:111868e5cb21

Regenerate xapian index on added attachment, fix PageDeletedEvent, fix header
author Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
date Sun, 22 Jul 2007 03:51:10 +0200
parents c707250dca17
children 41669a7a60ad
files MoinMoin/action/AttachFile.py MoinMoin/events/xapian_index.py
diffstat 2 files changed, 20 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/action/AttachFile.py	Sun Jul 22 03:27:22 2007 +0200
+++ b/MoinMoin/action/AttachFile.py	Sun Jul 22 03:51:10 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/events/xapian_index.py	Sun Jul 22 03:27:22 2007 +0200
+++ b/MoinMoin/events/xapian_index.py	Sun Jul 22 03:51:10 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)