diff options
author | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2011-04-27 12:32:54 -0400 |
---|---|---|
committer | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2011-04-27 12:32:54 -0400 |
commit | b8b18378669f57484ab7f4bdae49f8e6c99cac23 (patch) | |
tree | 5ecdf4fe93cf23f5b5dffe4b35d9db34fed1e323 | |
parent | 8b3ab52c3f7255bde44a0bf3534a569055acf1a2 (diff) | |
download | askbot-b8b18378669f57484ab7f4bdae49f8e6c99cac23.tar.gz askbot-b8b18378669f57484ab7f4bdae49f8e6c99cac23.tar.bz2 askbot-b8b18378669f57484ab7f4bdae49f8e6c99cac23.zip |
fixed issue with migration 22 on mysql and django >= 1.2
-rw-r--r-- | askbot/__init__.py | 32 | ||||
-rw-r--r-- | askbot/conf/__init__.py | 3 | ||||
-rw-r--r-- | askbot/migrations/0022_init_postgresql_full_text_search.py | 3 | ||||
-rw-r--r-- | askbot/models/question.py | 2 | ||||
-rw-r--r-- | setup.py | 5 |
5 files changed, 34 insertions, 11 deletions
diff --git a/askbot/__init__.py b/askbot/__init__.py index 17ca255e..74524337 100644 --- a/askbot/__init__.py +++ b/askbot/__init__.py @@ -8,15 +8,18 @@ import os import smtplib import sys import logging -from askbot import patches -from askbot.deployment.assertions import assert_package_compatibility -VERSION = (0, 6, 80) +VERSION = (0, 6, 81) #necessary for interoperability of django and coffin -assert_package_compatibility() -patches.patch_django() -patches.patch_coffin()#must go after django +try: + from askbot import patches + from askbot.deployment.assertions import assert_package_compatibility + assert_package_compatibility() + patches.patch_django() + patches.patch_coffin()#must go after django +except ImportError: + pass def get_install_directory(): """returns path to directory @@ -31,3 +34,20 @@ def get_version(): this version is meaningful for pypi only """ return '.'.join([str(subversion) for subversion in VERSION]) + +def get_database_engine_name(): + """returns name of the database engine, + independently of the version of django + - for django >=1.2 looks into ``settings.DATABASES['default']``, + (i.e. assumes that askbot uses database named 'default') + , and for django 1.1 and below returns settings.DATABASE_ENGINE + """ + import django + from django.conf import settings as django_settings + major_version = django.VERSION[0] + minor_version = django.VERSION[1] + if major_version == 1: + if minor_version > 1: + return django_settings.DATABASES['default']['ENGINE'] + else: + return django_settings.DATABASE_ENGINE diff --git a/askbot/conf/__init__.py b/askbot/conf/__init__.py index 05818b44..c25b6ed3 100644 --- a/askbot/conf/__init__.py +++ b/askbot/conf/__init__.py @@ -1,4 +1,5 @@ #import these to compile code and install values +import askbot import askbot.conf.minimum_reputation import askbot.conf.vote_rules import askbot.conf.reputation_changes @@ -23,4 +24,4 @@ def should_show_sort_by_relevance(): """True if configuration support sorting questions by search relevance """ - return (django_settings.DATABASE_ENGINE == 'postgresql_psycopg2') + return (askbot.get_database_engine_name() == 'postgresql_psycopg2') diff --git a/askbot/migrations/0022_init_postgresql_full_text_search.py b/askbot/migrations/0022_init_postgresql_full_text_search.py index 173c1f21..f973cdad 100644 --- a/askbot/migrations/0022_init_postgresql_full_text_search.py +++ b/askbot/migrations/0022_init_postgresql_full_text_search.py @@ -1,5 +1,6 @@ # encoding: utf-8 import datetime +import askbot from south.db import db from south.v2 import DataMigration from django.db import models @@ -10,7 +11,7 @@ class Migration(DataMigration): def forwards(self, orm): "Write your forwards methods here." - if settings.DATABASE_ENGINE == 'postgresql_psycopg2': + if askbot.get_database_engine_name() == 'postgresql_psycopg2': management.call_command('init_postgresql_full_text_search') def backwards(self, orm): diff --git a/askbot/models/question.py b/askbot/models/question.py index 99886ec9..f22232a5 100644 --- a/askbot/models/question.py +++ b/askbot/models/question.py @@ -135,7 +135,7 @@ class QuestionQuerySet(models.query.QuerySet): | models.Q(tagnames__search = search_query) \ | models.Q(answers__text__search = search_query) ) - elif settings.DATABASE_ENGINE == 'postgresql_psycopg2': + elif askbot.get_database_engine_name() == 'postgresql_psycopg2': rank_clause = "ts_rank(question.text_search_vector, to_tsquery(%s))"; search_query = '&'.join(search_query.split()) extra_params = ("'" + search_query + "'",) @@ -27,6 +27,7 @@ install_requires = [ #todo: have a dirty version retriever that #parses it out from askbot/__init__.py but does not #import it as there are issues +import askbot WIN_PLATFORMS = ('win32', 'cygwin',) if sys.platform not in WIN_PLATFORMS: @@ -34,7 +35,7 @@ if sys.platform not in WIN_PLATFORMS: setup( name = "askbot", - version = '0.6.80',#remember to manually set this correctly + version = askbot.get_version(),#version comes from askbot/__init__.py description = 'Question and Answer forum, like StackOverflow, written in python and Django', packages = find_packages(), author = 'Evgeny.Fadeev', @@ -150,7 +151,7 @@ if 'WIN_PLATFORM' in locals() and sys.platform in WIN_PLATFORMS: print '**************************************************************' print '* *' print '* Thanks for installing Askbot. *' -print '* To start deploying type: >python startforum *' +print '* To start deploying type: > startforum *' print '* Please take a look at the manual askbot/doc/INSTALL *' print '* And please do not hesitate to ask your questions at *' print '* at http://askbot.org *' |