From 3009ab1525991479e10da3867c8e248fe031c091 Mon Sep 17 00:00:00 2001 From: Marco Bonetti Date: Wed, 9 Jan 2013 15:03:01 +0100 Subject: [PATCH] added a test to check for DummyCache when using CacheRosettaStorage, which could explain issues #51 and #56 --- rosetta/__init__.py | 2 +- rosetta/storage.py | 6 ++++++ testproject/settings.py | 11 +++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/rosetta/__init__.py b/rosetta/__init__.py index 664a7c7..7655aad 100644 --- a/rosetta/__init__.py +++ b/rosetta/__init__.py @@ -1,4 +1,4 @@ -VERSION = (0, 6, 8) +VERSION = (0, 7, 0) def get_version(svn=False, limit=3): diff --git a/rosetta/storage.py b/rosetta/storage.py index 3e52443..f29dbca 100644 --- a/rosetta/storage.py +++ b/rosetta/storage.py @@ -1,5 +1,7 @@ from django.core.cache import cache +from django.conf import settings from django.utils import importlib +from django.core.exceptions import ImproperlyConfigured import hashlib import time @@ -56,6 +58,10 @@ class CacheRosettaStorage(BaseRosettaStorage): # so we need to per-user key prefix, which we store in the session def __init__(self, request): super(CacheRosettaStorage, self).__init__(request) + + if 'dummycache' in settings.CACHES['default']['BACKEND'].lower(): + raise ImproperlyConfigured("You can't use the CacheRosettaStorage if your cache isn't correctly set up (you are use the DummyCache cache backend).") + if 'rosetta_cache_storage_key_prefix' in self.request.session: self._key_prefix = self.request.session['rosetta_cache_storage_key_prefix'] else: diff --git a/testproject/settings.py b/testproject/settings.py index 2dece69..c92095e 100644 --- a/testproject/settings.py +++ b/testproject/settings.py @@ -17,6 +17,17 @@ DATABASES = { } } +CACHES = { + 'default': { + 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', + 'LOCATION': '127.0.0.1:11211', + 'KEY_PREFIX': 'ROSETTA_TEST' + } +} + + +#CACHES = {'default': {'BACKEND': 'django.core.cache.backends.dummy.DummyCache'}} + TEST_DATABASE_CHARSET = "utf8" TEST_DATABASE_COLLATION = "utf8_general_ci"