changeset 1012:2cfc385035cc

merged
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 29 Oct 2011 17:58:11 -0200
parents fc85c7c88c14 (current diff) e3dfe019a862 (diff)
children 57f6267eb050
files
diffstat 2 files changed, 15 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/storage/middleware/indexing.py	Sat Oct 29 17:26:24 2011 -0200
+++ b/MoinMoin/storage/middleware/indexing.py	Sat Oct 29 17:58:11 2011 -0200
@@ -64,7 +64,9 @@
 from whoosh.index import open_dir, create_in, EmptyIndexError
 from whoosh.writing import AsyncWriter
 from whoosh.filedb.multiproc import MultiSegmentWriter
-from whoosh.qparser import QueryParser, MultifieldParser, RegexPlugin
+from whoosh.qparser import QueryParser, MultifieldParser, RegexPlugin, \
+                           PseudoFieldPlugin
+from whoosh.qparser import WordNode
 from whoosh.query import Every, Term
 from whoosh.sorting import FieldFacet
 
@@ -73,7 +75,7 @@
                             CONTENT, ITEMLINKS, ITEMTRANSCLUSIONS, ACL, EMAIL, OPENID, \
                             ITEMID, REVID, CURRENT, PARENTID, \
                             LATEST_REVS, ALL_REVS
-
+from MoinMoin import user
 from MoinMoin.search.analyzers import item_name_analyzer, MimeTokenizer, AclTokenizer
 from MoinMoin.themes import utctimestamp
 from MoinMoin.util.crypto import make_uuid
@@ -575,6 +577,16 @@
             raise ValueError("default_fields list must at least contain one field name")
         # TODO before using the RegexPlugin, require a whoosh release that fixes whoosh issues #205 and #206
         #qp.add_plugin(RegexPlugin())
+        def username_pseudo_field(node):
+            username = node.text
+            users = user.search_users(**{NAME_EXACT: username})
+            if users:
+                userid = users[0].meta['userid']
+                node = WordNode(userid)
+                node.set_fieldname("userid")
+                return node
+            return node
+        qp.add_plugin(PseudoFieldPlugin({'username': username_pseudo_field}))
         return qp
 
     def search(self, q, idx_name=LATEST_REVS, **kw):
--- a/MoinMoin/templates/error.html	Sat Oct 29 17:26:24 2011 -0200
+++ b/MoinMoin/templates/error.html	Sat Oct 29 17:58:11 2011 -0200
@@ -1,6 +1,6 @@
 {% extends theme("layout.html") %}
 {% block content %}
 <h1>{{ title }}</h1>
-{{ description }}
+<p>{{ description }}</p>
 {% endblock %}