Fixed cache setting handling. Fixes issue #4.

This commit is contained in:
Jannis Leidel 2011-04-14 13:38:09 +02:00
parent e11c2ee71d
commit ae6818f745
2 changed files with 7 additions and 9 deletions

View file

@ -2,10 +2,12 @@ import posixpath
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
# If we are on Django 1.3 AND using the new CACHES setting...
cache = getattr(settings, "CACHES", {}).get("dbtemplates",
# .. or fall back to the old CACHE_BACKEND setting
getattr(settings, "DBTEMPLATES_CACHE_BACKEND", None))
if "dbtemplates" in getattr(settings, "CACHES", {}):
# If we are on Django 1.3 AND using the new CACHES setting..
cache = "dbtemplates"
else:
# ..or fall back to the old CACHE_BACKEND setting
cache = getattr(settings, "DBTEMPLATES_CACHE_BACKEND", None)
if not cache:
raise ImproperlyConfigured("Please specify a dbtemplates "
"cache backend in your settings.")

View file

@ -9,11 +9,7 @@ from dbtemplates import settings
def get_cache_backend():
if "://" in settings.CACHE_BACKEND:
cache = get_cache(settings.CACHE_BACKEND)
else:
cache = get_cache(**settings.CACHE_BACKEND)
return cache
return get_cache(settings.CACHE_BACKEND)
cache = get_cache_backend()