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)
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)
def __init__(self): super(Config, self).__setattr__('_backend', utils.import_module_attr(settings.BACKEND)()) if settings.RETRIEVE_ALL_KEYS: super(Config, self).__setattr__('_keys',{})
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)
def load_config_class(): return utils.import_module_attr(settings.CONFIG_CLASS)
def __init__(self): super(Config, self).__setattr__('_backend', utils.import_module_attr(settings.BACKEND)())