]> git.openstreetmap.org Git - osqa.git/blob - forum_modules/pgfulltext/management.py
improved text search
[osqa.git] / forum_modules / pgfulltext / management.py
1 import os
2
3 from django.db import connection, transaction
4 from django.conf import settings
5
6 import forum.models
7
8 if settings.DATABASE_ENGINE in ('postgresql_psycopg2', 'postgresql', ):
9     from django.db.models.signals import post_syncdb
10
11     def install_pg_fts():
12         f = open(os.path.join(os.path.dirname(__file__), 'pg_fts_install.sql'), 'r')
13
14         try:
15             cursor = connection.cursor()
16             cursor.execute(f.read())
17             transaction.commit_unless_managed()
18         except:
19             pass
20         finally:
21             cursor.close()
22
23         f.close()
24
25     post_syncdb.connect(install_pg_fts, sender=forum.models, weak=False)
26
27