Simplify IMAGEKIT_CACHE_BACKEND setting

This commit is contained in:
Matthew Tretter 2012-10-04 23:41:20 -04:00
parent 436a73dc9a
commit 667f0cc08e
2 changed files with 7 additions and 3 deletions

View file

@ -1,4 +1,5 @@
from appconf import AppConf
from django.conf import settings
from .imagecache.actions import validate_now, clear_now
@ -8,3 +9,8 @@ class ImageKitConf(AppConf):
CACHE_DIR = 'CACHE/images'
CACHE_PREFIX = 'ik-'
DEFAULT_IMAGE_CACHE_STRATEGY = 'imagekit.imagecache.strategies.Pessimistic'
def configure_cache_backend(self, value):
if value is None:
value = 'django.core.cache.backends.dummy.DummyCache' if settings.DEBUG else 'default'
return value

View file

@ -1,6 +1,5 @@
from ..utils import get_singleton
from django.core.cache import get_cache
from django.core.cache.backends.dummy import DummyCache
from django.core.exceptions import ImproperlyConfigured
@ -23,8 +22,7 @@ class CachedValidationBackend(object):
def cache(self):
if not getattr(self, '_cache', None):
from django.conf import settings
alias = settings.IMAGEKIT_CACHE_BACKEND
self._cache = get_cache(alias) if alias else DummyCache(None, {})
self._cache = get_cache(settings.IMAGEKIT_CACHE_BACKEND)
return self._cache
def get_key(self, file):