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