changeset 5022:a93283d1f827

Xapian2009: XAPIAN_MIN_VERSION is 1.0.6, events.xapian_index doesn't raise an exception when old xapian is installed.
author Dmitrijs Milajevs <dimazest@gmail.com>
date Tue, 18 Aug 2009 17:40:59 +0200
parents fb0ddee3f5ff
children 11ce9cde8f85
files MoinMoin/events/xapian_index.py MoinMoin/search/Xapian.py
diffstat 2 files changed, 16 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/events/xapian_index.py	Sun Aug 16 15:43:53 2009 +0200
+++ b/MoinMoin/events/xapian_index.py	Tue Aug 18 17:40:59 2009 +0200
@@ -7,15 +7,21 @@
 """
 import MoinMoin.events as ev
 
+def _get_index(request):
+    try:
+        from MoinMoin.search.Xapian import Index
+        return Index(request)
+    except ImportError:
+        pass
+
 def handle_renamed(event):
     """Updates Xapian index when a page changes its name"""
 
     request = event.request
 
     if request.cfg.xapian_search:
-        from MoinMoin.search.Xapian import Index
-        index = Index(request)
-        if index.exists():
+        index = _get_index(request)
+        if index and index.exists():
             index.remove_item(event.old_page.page_name, now=0)
             index.update_page(event.page.page_name)
 
@@ -26,9 +32,8 @@
     request = event.request
 
     if request.cfg.xapian_search:
-        from MoinMoin.search.Xapian import Index
-        index = Index(request)
-        if index.exists():
+        index = _get_index(request)
+        if index and index.exists():
             index.update_page(event.page.page_name)
 
 def handle_changed(event, deleted=False):
@@ -37,9 +42,8 @@
     request = event.request
 
     if request.cfg.xapian_search:
-        from MoinMoin.search.Xapian import Index
-        index = Index(request)
-        if index.exists():
+        index = _get_index(request)
+        if index and index.exists():
             if deleted:
                 index.remove_item(event.page.page_name)
             else:
@@ -58,9 +62,8 @@
     request = event.request
 
     if request.cfg.xapian_search:
-        from MoinMoin.search.Xapian import Index
-        index = Index(request)
-        if index.exists():
+        index = _get_index(request)
+        if index and index.exists():
             index.update_page(event.pagename)
 
 
--- a/MoinMoin/search/Xapian.py	Sun Aug 16 15:43:53 2009 +0200
+++ b/MoinMoin/search/Xapian.py	Tue Aug 18 17:40:59 2009 +0200
@@ -238,9 +238,8 @@
 
     def _check_version(self):
         """ Checks if the correct version of Xapian is installed """
-        # XXX xappy checks version on import!
         # every version greater than or equal to XAPIAN_MIN_VERSION is allowed
-        XAPIAN_MIN_VERSION = (1, 0, 0)
+        XAPIAN_MIN_VERSION = (1, 0, 6)
         major, minor, revision = xapian.major_version(), xapian.minor_version(), xapian.revision()
         if (major, minor, revision) >= XAPIAN_MIN_VERSION:
             return