summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvgeny Fadeev <evgeny.fadeev@gmail.com>2011-06-18 16:25:02 -0400
committerEvgeny Fadeev <evgeny.fadeev@gmail.com>2011-06-18 16:25:02 -0400
commit1118a6e8d5ecf4a8d3a6ab7c75cba13194fec377 (patch)
tree42fc342ab925a1c8a31000eb46872befa49739dc
parent369ab0e2b50b1fb329d068f11237561d27b90f28 (diff)
downloadaskbot-1118a6e8d5ecf4a8d3a6ab7c75cba13194fec377.tar.gz
askbot-1118a6e8d5ecf4a8d3a6ab7c75cba13194fec377.tar.bz2
askbot-1118a6e8d5ecf4a8d3a6ab7c75cba13194fec377.zip
added a startup check for USE_I18N = True
-rw-r--r--askbot/startup_procedures.py20
1 files changed, 14 insertions, 6 deletions
diff --git a/askbot/startup_procedures.py b/askbot/startup_procedures.py
index dffca0f1..63737acc 100644
--- a/askbot/startup_procedures.py
+++ b/askbot/startup_procedures.py
@@ -8,7 +8,7 @@ question: why not run these from askbot/__init__.py?
the main function is run_startup_tests
"""
from django.db import transaction
-from django.conf import settings
+from django.conf import settings as django_settings
from django.core.exceptions import ImproperlyConfigured
from askbot.models import badges
@@ -20,7 +20,7 @@ def test_askbot_url():
well-formedness and raises the ImproperlyConfigured
exception, if the setting is not good.
"""
- url = settings.ASKBOT_URL
+ url = django_settings.ASKBOT_URL
if url != '':
if isinstance(url, str) or isinstance(url, unicode):
@@ -64,22 +64,29 @@ def test_middleware():
#'debug_toolbar.middleware.DebugToolbarMiddleware',
missing_middleware = list()
for middleware in required_middleware:
- if middleware not in settings.MIDDLEWARE_CLASSES:
+ if middleware not in django_settings.MIDDLEWARE_CLASSES:
missing_middleware.append(middleware)
debug_toolbar_middleware = 'debug_toolbar.middleware.DebugToolbarMiddleware'
- if 'debug_toolbar' in settings.INSTALLED_APPS:
- if debug_toolbar_middleware not in settings.MIDDLEWARE_CLASSES:
+ if 'debug_toolbar' in django_settings.INSTALLED_APPS:
+ if debug_toolbar_middleware not in django_settings.MIDDLEWARE_CLASSES:
missing_middleware.append(debug_toolbar_middleware)
if missing_middleware:
error_message = """Please add the following middleware (listed
after this message) to the MIDDLEWARE_CLASSES variable in your site settings.py file.
The order the middleware records may be important, please take a look at the example in
-https://github.com/ASKBOT/askbot-devel/blob/master/askbot/setup_templates/settings.py\n\n%s""" \
+https://github.com/ASKBOT/askbot-devel/blob/master/askbot/setup_templates/settings.jy\n\n%s""" \
% ', '.join(missing_middleware)
raise ImproperlyConfigured(error_message)
+def test_i18n():
+ if getattr(django_settings, 'USE_I18N', False) == False:
+ raise ImproperlyConfigured(
+ 'Please set USE_I18N = True in settings.py and '
+ 'set the LANGUAGE_CODE parameter correctly '
+ 'it is very important for askbot.'
+ )
def run_startup_tests():
"""function that runs
@@ -88,6 +95,7 @@ def run_startup_tests():
#todo: refactor this when another test arrives
test_askbot_url()
+ test_i18n()
test_middleware()
@transaction.commit_manually