Mercurial > moin > 2.0
changeset 780:f5e0f85e66ce pytest2
whooshify get_index()
author | Thomas Waldmann <tw AT waldmann-edv DOT de> |
---|---|
date | Sat, 27 Aug 2011 19:11:21 +0200 |
parents | 815c46100e2c |
children | 33bfaf10d752 |
files | MoinMoin/items/__init__.py |
diffstat | 1 files changed, 7 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/MoinMoin/items/__init__.py Sat Aug 27 18:21:04 2011 +0200 +++ b/MoinMoin/items/__init__.py Sat Aug 27 19:11:21 2011 +0200 @@ -26,7 +26,7 @@ from flatland import Form, String, Integer, Boolean, Enum from flatland.validation import Validator, Present, IsEmail, ValueBetween, URLValidator, Converted -from whoosh.query import Term, And +from whoosh.query import Term, And, Prefix from MoinMoin.util.forms import FileStorage @@ -555,25 +555,20 @@ def get_index(self): """ create an index of sub items of this item """ - import re - from MoinMoin.storage.terms import NameRE - if self.name: prefix = self.name + u'/' + query = And([Term("wikiname", app.cfg.interwikiname), Prefix("name_exact", prefix)]) else: # trick: an item of empty name can be considered as "virtual root item", # that has all wiki items as sub items prefix = u'' - sub_item_re = u"^%s.*" % re.escape(prefix) - regex = re.compile(sub_item_re, re.UNICODE) - - item_iterator = self.search_items(NameRE(regex)) - + query = Term("wikiname", app.cfg.interwikiname) + results = flaskg.storage.search(query, all_revs=False, sortedby="name_exact", limit=None) # We only want the sub-item part of the item names, not the whole item objects. prefix_len = len(prefix) - items = [(item.name, item.name[prefix_len:], item.meta.get(CONTENTTYPE)) - for item in item_iterator] - return sorted(items) + items = [(result[NAME], result[NAME][prefix_len:], result[CONTENTTYPE]) + for result in results] + return items def flat_index(self, startswith=None, selected_groups=None): """