Skip to content

Commit

Permalink
added a test to check for DummyCache when using CacheRosettaStorage, …
Browse files Browse the repository at this point in the history
…which could explain issues #51 and #56
  • Loading branch information
mbi committed Jan 9, 2013
1 parent 5a51e39 commit 3009ab1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion rosetta/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION = (0, 6, 8)
VERSION = (0, 7, 0)


def get_version(svn=False, limit=3):
Expand Down
6 changes: 6 additions & 0 deletions rosetta/storage.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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:
Expand Down
11 changes: 11 additions & 0 deletions testproject/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@
}
}

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"

Expand Down

0 comments on commit 3009ab1

Please sign in to comment.