changeset 2221:f5b9f51e67a9

fix xapian version check, use non-deprecated functions for it with fallback to depracated functions
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 26 May 2007 19:12:16 +0200
parents 2be09fd7a1c9
children 90484c86443a
files MoinMoin/macro/SystemInfo.py MoinMoin/search/Xapian.py
diffstat 2 files changed, 15 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/macro/SystemInfo.py	Sat May 26 18:49:43 2007 +0200
+++ b/MoinMoin/macro/SystemInfo.py	Sat May 26 19:12:16 2007 +0200
@@ -144,7 +144,10 @@
 
         try:
             import xapian
-            xapVersion = xapian.xapian_version_string()
+            try:
+                xapVersion = xapian.version_string()
+            except AttributeError:
+                xapVersion = xapian.xapian_version_string() # deprecated since xapian 0.9.6, removal in 1.1.0
         except ImportError:
             xapVersion = _('Xapian and/or Python Xapian bindings not installed')
 
--- a/MoinMoin/search/Xapian.py	Sat May 26 18:49:43 2007 +0200
+++ b/MoinMoin/search/Xapian.py	Sat May 26 19:12:16 2007 +0200
@@ -219,16 +219,20 @@
 
     def _check_version(self):
         """ Checks if the correct version of Xapian is installed """
-        # every version greater than or equal to 0.9.6 is allowed for now
-        # Note: fails if crossing the 10.x barrier
-        if xapian.xapian_version_string() >= '0.9.6':
+        # every version greater than or equal to XAPIAN_MIN_VERSION is allowed
+        XAPIAN_MIN_VERSION = (0, 9, 6)
+        try:
+           major, minor, revision = xapian.major_version(), xapian.minor_version(), xapian.revision()
+        except AttributeError:
+           major, minor, revision = xapian.xapian_major_version(), xapian.xapian_minor_version(), xapian.xapian_revision() # deprecated since xapian 0.9.6, removal in 1.1.0
+        if (major, minor, revision) >= XAPIAN_MIN_VERSION:
             return
 
         from MoinMoin.error import ConfigurationError
-        raise ConfigurationError('MoinMoin needs at least Xapian version '
-                '0.9.6 to work correctly. Either disable Xapian '
-                'completetly in your wikiconfig or upgrade your Xapian '
-                'installation!')
+        raise ConfigurationError(('MoinMoin needs at least Xapian version '
+                '%d.%d.%d to work correctly. Either disable Xapian '
+                'completetly in your wikiconfig or upgrade your Xapian %d.%d.%d '
+                'installation!') % (XAPIAN_MIN_VERSION + (major, minor, revision)))
 
     def _main_dir(self):
         """ Get the directory of the xapian index """