]> git.openstreetmap.org Git - osqa.git/blob - forum_modules/pgfulltext/management.py
several improvements in the caching system
[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 def install_pg_fts(**kwargs):
9     f = open(os.path.join(os.path.dirname(__file__), 'pg_fts_install.sql'), 'r')
10
11     try:
12         cursor = connection.cursor()
13         cursor.execute(f.read())
14         transaction.commit_unless_managed()
15     except:
16         pass
17     finally:
18         cursor.close()
19
20     f.close()
21
22 if settings.DATABASE_ENGINE in ('postgresql_psycopg2', 'postgresql', ):
23     from django.db.models.signals import post_syncdb
24     post_syncdb.connect(install_pg_fts, sender=forum.models, weak=False)
25
26
27 try:
28     from south.signals import post_migrate
29     post_migrate.connect(install_pg_fts, weak=False)
30 except:
31     pass