changeset 3552:7d9b8040e3be

Xapian search / stemming: fix crash if default language is un-stemmable
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 03 May 2008 22:46:14 +0200
parents a8acceca815a
children 1052c105b16f
files MoinMoin/search/Xapian.py
diffstat 1 files changed, 7 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/search/Xapian.py	Sat May 03 19:31:44 2008 +0200
+++ b/MoinMoin/search/Xapian.py	Sat May 03 22:46:14 2008 +0200
@@ -97,10 +97,13 @@
         @param request: current request
         @param language: if given, the language in which to stem words
         """
-        if request and request.cfg.xapian_stemming and language:
-            self.stemmer = Stemmer(language)
-        else:
-            self.stemmer = None
+        self.stemmer = None
+        if request and request.cfg.xapian_stemming and language and Stemmer:
+            try:
+                self.stemmer = Stemmer(language)
+            except (KeyError, TypeError):
+                # lang is not stemmable or not available
+                pass
 
     def raw_tokenize(self, value):
         """ Yield a stream of lower cased raw and stemmed words from a string.