X-Git-Url: https://git.openstreetmap.org./osqa.git/blobdiff_plain/f8bdcf43ec75e04c30cb26e6c35e1a9f3cf262be..9b450de133375fb612625b826f1920b672ab2acc:/forum_modules/pgfulltext/management.py diff --git a/forum_modules/pgfulltext/management.py b/forum_modules/pgfulltext/management.py index c2abfaf..60baecd 100644 --- a/forum_modules/pgfulltext/management.py +++ b/forum_modules/pgfulltext/management.py @@ -5,23 +5,27 @@ from django.conf import settings import forum.models -if settings.DATABASE_ENGINE in ('postgresql_psycopg2', 'postgresql', ): - from django.db.models.signals import post_syncdb - - def install_pg_fts(): - f = open(os.path.join(os.path.dirname(__file__), 'pg_fts_install.sql'), 'r') +def install_pg_fts(**kwargs): + f = open(os.path.join(os.path.dirname(__file__), 'pg_fts_install.sql'), 'r') - try: - cursor = connection.cursor() - cursor.execute(f.read()) - transaction.commit_unless_managed() - except: - pass - finally: - cursor.close() + try: + cursor = connection.cursor() + cursor.execute(f.read()) + transaction.commit_unless_managed() + except: + pass + finally: + cursor.close() - f.close() + f.close() +if settings.DATABASE_ENGINE in ('postgresql_psycopg2', 'postgresql', ): + from django.db.models.signals import post_syncdb post_syncdb.connect(install_pg_fts, sender=forum.models, weak=False) +try: + from south.signals import post_migrate + post_migrate.connect(install_pg_fts, weak=False) +except: + pass \ No newline at end of file