]> git.openstreetmap.org Git - osqa.git/blob - forum_modules/pgfulltext/startup.py
changing the install file so that is simply points to OSQA's wiki.
[osqa.git] / forum_modules / pgfulltext / startup.py
1 import os\r
2 from forum.models import KeyValue\r
3 from django.db import connection, transaction\r
4 \r
5 KEY = 'PG_FTSTRIGGERS_VERSION'\r
6 VERSION = 3\r
7 install = False\r
8 \r
9 try:\r
10     version = KeyValue.objects.get(key=KEY).value\r
11     if version < VERSION:\r
12         install = True\r
13 except:\r
14     install = True\r
15 \r
16 \r
17 if install:\r
18     print 'install'\r
19     f = open(os.path.join(os.path.dirname(__file__), 'pg_fts_install.sql'), 'r')\r
20 \r
21     try:\r
22         cursor = connection.cursor()\r
23         cursor.execute(f.read())\r
24         transaction.commit_unless_managed()\r
25 \r
26         try:\r
27             kv = KeyValue.objects.get(key=KEY)\r
28         except:\r
29             kv = KeyValue(key=KEY)\r
30 \r
31         kv.value = VERSION\r
32         kv.save()\r
33         \r
34     except Exception, e:\r
35         import sys, traceback\r
36         traceback.print_exc(file=sys.stdout)\r
37         pass\r
38     finally:\r
39         cursor.close()\r
40 \r
41     f.close()\r