changeset 2649:3878ffc317da

xmlrpc_searchPagesEx() with more options and no html formatting of output.
author Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
date Tue, 07 Aug 2007 03:14:32 +0200
parents 6e323cf20c64
children 2b4be3be9835
files MoinMoin/xmlrpc/__init__.py
diffstat 1 files changed, 30 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/xmlrpc/__init__.py	Mon Aug 06 20:49:08 2007 +0200
+++ b/MoinMoin/xmlrpc/__init__.py	Tue Aug 07 03:14:32 2007 +0200
@@ -567,6 +567,36 @@
         return [(self._outstr(hit.page_name),
                  self._outstr(results.formatContext(hit, 180, 1)))
                 for hit in results.hits]
+        
+    def xmlrpc_searchPagesEx(self, query_string, search_type, length, case, mtime, regexp):
+        """ Searches pages for query_string - extended version for compatibility
+        
+        This function, in contrary to searchPages(), doesn't return HTML-formatted data.
+        
+        @param query_string: term to search for
+        @param search_type: "text" or "title" search
+        @param length: length of context preview (in characters)
+        @param case: should the search be case sensitive?
+        @param mtime: only output pages modified after mtime
+        @param regexp: should the query_string be treates as a regular expression?
+        @return: (page name, context preview, page url)
+        
+        """
+        from MoinMoin import search
+        from MoinMoin.formatter.text_plain import Formatter
+
+        kwargs = {"sort": "page_name", "case": case, "regex": regexp}
+        if search_type == "title":
+            kwargs["titlesearch"] = True
+            
+        results = search.searchPages(self.request, query_string, **kwargs)
+        results.formatter = Formatter(self.request)
+        results.request = self.request
+
+        return [(self._outstr(hit.page_name),
+                 self._outstr(results.formatContext(hit, length, 1)),
+                 self.request.getQualifiedURL(hit.page.url(self.request, {}, relative=False)))
+                for hit in results.hits]            
 
     def xmlrpc_getMoinVersion(self):
         """ Returns a tuple of the MoinMoin version: