コード例 #1
0
ファイル: redisd.py プロジェクト: pdr/django-constance
 def __init__(self):
     super(RedisBackend, self).__init__()
     self._prefix = settings.PREFIX
     connection_cls = settings.CONNECTION_CLASS
     if connection_cls is not None:
         self._rd = utils.import_module_attr(connection_cls)()
     else:
         try:
             import redis
         except ImportError:
             raise ImproperlyConfigured(
                 "The Redis backend requires redis-py to be installed.")
         self._rd = redis.Redis(**settings.REDIS_CONNECTION)
コード例 #2
0
ファイル: redisd.py プロジェクト: pdr/django-constance
 def __init__(self):
     super(RedisBackend, self).__init__()
     self._prefix = settings.PREFIX
     connection_cls = settings.CONNECTION_CLASS
     if connection_cls is not None:
         self._rd = utils.import_module_attr(connection_cls)()
     else:
         try:
             import redis
         except ImportError:
             raise ImproperlyConfigured(
                 "The Redis backend requires redis-py to be installed.")
         self._rd = redis.Redis(**settings.REDIS_CONNECTION)
コード例 #3
0
ファイル: settings.py プロジェクト: slafs/django-constance
import os
from constance.utils import import_module_attr

settings = import_module_attr(
    os.getenv('CONSTANCE_SETTINGS_MODULE', 'django.conf.settings'))

PREFIX = getattr(settings, 'CONSTANCE_REDIS_PREFIX',
                 getattr(settings, 'CONSTANCE_PREFIX', 'constance:'))

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)
コード例 #4
0
 def __init__(self):
     super(Config, self).__setattr__('_backend',
         utils.import_module_attr(settings.BACKEND)())
     if settings.RETRIEVE_ALL_KEYS:
         super(Config, self).__setattr__('_keys',{})
コード例 #5
0
import os
from constance.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:'))

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)

DATABASE_PREFIX = getattr(settings, 'CONSTANCE_DATABASE_PREFIX', '')

SUPERUSER_ONLY = getattr(settings, 'CONSTANCE_SUPERUSER_ONLY', True)

RETRIEVE_ALL_KEYS = getattr(settings, 'CONSTANCE_RETRIEVE_ALL_KEYS', False)
コード例 #6
0
def load_config_class():
    return utils.import_module_attr(settings.CONFIG_CLASS)
コード例 #7
0
 def __init__(self):
     super(Config, self).__setattr__('_backend',
         utils.import_module_attr(settings.BACKEND)())
コード例 #8
0
 def __init__(self):
     super(Config, self).__setattr__('_backend',
         utils.import_module_attr(settings.BACKEND)())