diff MoinMoin/config/multiconfig.py @ 2989:c678e73b7730

auto-disable xapian_search when xapian fails to import (port from 1.6)
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 06 Jan 2008 16:08:11 +0100
parents af66750c66e4
children 0ae378dc1edf
line wrap: on
line diff
--- a/MoinMoin/config/multiconfig.py	Sun Jan 06 16:06:43 2008 +0100
+++ b/MoinMoin/config/multiconfig.py	Sun Jan 06 16:08:11 2008 +0100
@@ -11,6 +11,7 @@
 import os
 import sys
 import time
+import logging
 
 from MoinMoin import config, error, util, wikiutil
 import MoinMoin.auth as authmodule
@@ -372,12 +373,6 @@
                                     # instead of just IPs
     log_timing = False              # update <data_dir>/timing.log?
 
-    xapian_search = False
-    xapian_index_dir = None
-    xapian_stemming = True
-    xapian_index_history = False
-    search_results_per_page = 10
-
     mail_login = None # or "user pwd" if you need to use SMTP AUTH
     mail_sendmail = None # "/usr/sbin/sendmail -t -i" to not use SMTP, but sendmail
     mail_smarthost = None
@@ -701,6 +696,12 @@
     unzip_attachments_space = 200.0 * 1000 ** 2
     unzip_attachments_count = 101 # 1 zip file + 100 files contained in it
 
+    xapian_search = False
+    xapian_index_dir = None
+    xapian_stemming = True
+    xapian_index_history = False
+    search_results_per_page = 10
+
     SecurityPolicy = None
 
     def __init__(self, siteid):
@@ -776,6 +777,14 @@
         self.navi_bar = [elem % self for elem in self.navi_bar]
         self.backup_exclude = [elem % self for elem in self.backup_exclude]
 
+        # check if python-xapian is installed
+        if self.xapian_search:
+            try:
+                import xapian
+            except ImportError, err:
+                self.xapian_search = False
+                logging.error("xapian_search was auto-disabled because python-xapian is not installed [%s]." % str(err))
+
         # list to cache xapian searcher objects
         self.xapian_searchers = []