]> git.openstreetmap.org Git - osqa.git/blobdiff - forum_modules/pgfulltext/startup.py
Fix OSQA 257, Improve search algorithm.
[osqa.git] / forum_modules / pgfulltext / startup.py
index 32a7992e76af23d6406cb261410e7719352e7d62..0eb3f3901e1d11a95a37ff8f38305e260523ea67 100644 (file)
@@ -1,21 +1,11 @@
 import os\r
 from forum.models import KeyValue\r
 from django.db import connection, transaction\r
+import settings\r
 \r
-KEY = 'PG_FTSTRIGGERS_VERSION'\r
-VERSION = 3\r
-install = False\r
+VERSION = 6\r
 \r
-try:\r
-    version = KeyValue.objects.get(key=KEY).value\r
-    if version < VERSION:\r
-        install = True\r
-except:\r
-    install = True\r
-\r
-\r
-if install:\r
-    print 'install'\r
+if int(settings.PG_FTSTRIGGERS_VERSION) < VERSION:\r
     f = open(os.path.join(os.path.dirname(__file__), 'pg_fts_install.sql'), 'r')\r
 \r
     try:\r
@@ -23,19 +13,15 @@ if install:
         cursor.execute(f.read())\r
         transaction.commit_unless_managed()\r
 \r
-        try:\r
-            kv = KeyValue.objects.get(key=KEY)\r
-        except:\r
-            kv = KeyValue(key=KEY)\r
-\r
-        kv.value = VERSION\r
-        kv.save()\r
+        settings.PG_FTSTRIGGERS_VERSION.set_value(VERSION)\r
         \r
     except Exception, e:\r
-        import sys, traceback\r
-        traceback.print_exc(file=sys.stdout)\r
+        #import sys, traceback\r
+        #traceback.print_exc(file=sys.stdout)\r
         pass\r
     finally:\r
         cursor.close()\r
 \r
     f.close()\r
+\r
+import handlers\r