changeset 920:a2498260eca5

do result processing in results.py
author Franz Pletz <fpletz AT franz-pletz DOT org>
date Tue, 27 Jun 2006 15:20:08 +0200
parents 5469c8b911a4
children 45e286183872
files MoinMoin/search/builtin.py MoinMoin/search/results.py
diffstat 2 files changed, 18 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/search/builtin.py	Tue Jun 27 15:09:46 2006 +0200
+++ b/MoinMoin/search/builtin.py	Tue Jun 27 15:20:08 2006 +0200
@@ -13,7 +13,7 @@
 import time, sys
 from MoinMoin import wikiutil, config
 from MoinMoin.Page import Page
-from MoinMoin.search.results import FoundRemote, FoundPage, FoundAttachment, SearchResults
+from MoinMoin.search.results import getSearchResults
 
 try:
     from MoinMoin.search import Xapian
@@ -45,19 +45,9 @@
         # important - filter deleted pages or pages the user may not read!
         if not self.filtered:
             hits = self._filter(hits)
+
+        return getSearchResults(self.request, self.query, hits, start)
         
-        result_hits = []
-        for wikiname, page, attachment, match in hits:
-            if wikiname in (self.request.cfg.interwikiname, 'Self'): # a local match
-                if attachment:
-                    result_hits.append(FoundAttachment(page.page_name, attachment))
-                else:
-                    result_hits.append(FoundPage(page.page_name, match))
-            else:
-                result_hits.append(FoundRemote(wikiname, page, attachment, match))
-        elapsed = time.time() - start
-        count = self.request.rootpage.getPageCount()
-        return SearchResults(self.query, result_hits, count, elapsed)
 
     # ----------------------------------------------------------------
     # Private!
--- a/MoinMoin/search/results.py	Tue Jun 27 15:09:46 2006 +0200
+++ b/MoinMoin/search/results.py	Tue Jun 27 15:20:08 2006 +0200
@@ -10,7 +10,7 @@
     @license: GNU GPL, see COPYING for details
 """
 
-import StringIO
+import StringIO, time
 from MoinMoin import config, wikiutil
 from MoinMoin.Page import Page
 
@@ -640,3 +640,17 @@
         self.matchLabel = (_('match'), _('matches'))
 
 
+def getSearchResults(request, query, hits, start):
+    result_hits = []
+    for wikiname, page, attachment, match in hits:
+        if wikiname in (request.cfg.interwikiname, 'Self'): # a local match
+            if attachment:
+                result_hits.append(FoundAttachment(page.page_name, attachment))
+            else:
+                result_hits.append(FoundPage(page.page_name, match))
+        else:
+            result_hits.append(FoundRemote(wikiname, page, attachment, match))
+    elapsed = time.time() - start
+    count = request.rootpage.getPageCount()
+    return SearchResults(query, result_hits, count, elapsed)
+