From fc930442a2fb941d8c952ddcbb38f9edfb1c1a86 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Tue, 25 Nov 2014 22:19:52 +0100 Subject: [PATCH] Simplified settings. --- constance/backends/redisd.py | 2 +- constance/settings.py | 23 ++++++++--------------- docs/changes.rst | 4 ++++ example/cheeseshop/settings.py | 2 +- tests/settings.py | 2 +- 5 files changed, 15 insertions(+), 18 deletions(-) diff --git a/constance/backends/redisd.py b/constance/backends/redisd.py index e612606..48232bf 100644 --- a/constance/backends/redisd.py +++ b/constance/backends/redisd.py @@ -17,7 +17,7 @@ class RedisBackend(Backend): def __init__(self): super(RedisBackend, self).__init__() self._prefix = settings.REDIS_PREFIX - connection_cls = settings.CONNECTION_CLASS + connection_cls = settings.REDIS_CONNECTION_CLASS if connection_cls is not None: self._rd = utils.import_module_attr(connection_cls)() else: diff --git a/constance/settings.py b/constance/settings.py index 18625be..6f1350d 100644 --- a/constance/settings.py +++ b/constance/settings.py @@ -1,24 +1,10 @@ -import os -from .utils import import_module_attr - -settings = import_module_attr( - os.getenv('CONSTANCE_SETTINGS_MODULE', 'django.conf.settings') -) - -REDIS_PREFIX = getattr(settings, 'CONSTANCE_REDIS_PREFIX', - getattr(settings, 'CONSTANCE_PREFIX', 'constance:')) +from django.conf import settings BACKEND = getattr(settings, 'CONSTANCE_BACKEND', 'constance.backends.redisd.RedisBackend') CONFIG = getattr(settings, 'CONSTANCE_CONFIG', {}) -CONNECTION_CLASS = getattr(settings, 'CONSTANCE_REDIS_CONNECTION_CLASS', - getattr(settings, 'CONSTANCE_CONNECTION_CLASS', None)) - -REDIS_CONNECTION = getattr(settings, 'CONSTANCE_REDIS_CONNECTION', - getattr(settings, 'CONSTANCE_CONNECTION', {})) - DATABASE_CACHE_BACKEND = getattr(settings, 'CONSTANCE_DATABASE_CACHE_BACKEND', None) @@ -28,4 +14,11 @@ DATABASE_CACHE_AUTOFILL_TIMEOUT = getattr(settings, DATABASE_PREFIX = getattr(settings, 'CONSTANCE_DATABASE_PREFIX', '') +REDIS_PREFIX = getattr(settings, 'CONSTANCE_REDIS_PREFIX', 'constance:') + +REDIS_CONNECTION_CLASS = getattr(settings, 'CONSTANCE_REDIS_CONNECTION_CLASS', + None) + +REDIS_CONNECTION = getattr(settings, 'CONSTANCE_REDIS_CONNECTION', {}) + SUPERUSER_ONLY = getattr(settings, 'CONSTANCE_SUPERUSER_ONLY', True) diff --git a/docs/changes.rst b/docs/changes.rst index 8a635b3..194ecb7 100644 --- a/docs/changes.rst +++ b/docs/changes.rst @@ -22,6 +22,10 @@ v1.0 (unreleased) ``CONSTANCE_PREFIX`` ``CONSTANCE_REDIS_PREFIX`` ============================== =================================== +* The undocumented feature to use an environment variable called + ``CONSTANCE_SETTINGS_MODULE`` to define which module to load + settings from has been removed. + v0.6 (2013/04/12) ~~~~~~~~~~~~~~~~~ diff --git a/example/cheeseshop/settings.py b/example/cheeseshop/settings.py index e69e60e..049c3d9 100644 --- a/example/cheeseshop/settings.py +++ b/example/cheeseshop/settings.py @@ -102,7 +102,7 @@ INSTALLED_APPS = ( 'constance.backends.database', ) -CONSTANCE_CONNECTION = { +CONSTANCE_REDIS_CONNECTION = { 'host': 'localhost', 'port': 6379, 'db': 0, diff --git a/tests/settings.py b/tests/settings.py index 5d91248..efad0ce 100644 --- a/tests/settings.py +++ b/tests/settings.py @@ -43,7 +43,7 @@ INSTALLED_APPS = ( ROOT_URLCONF = 'tests.urls' -CONSTANCE_CONNECTION_CLASS = 'tests.redis_mockup.Connection' +CONSTANCE_REDIS_CONNECTION_CLASS = 'tests.redis_mockup.Connection' long_value = 123456