summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2009-03-01 07:33:45 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2009-03-01 07:33:45 +0000
commit4d2de7a3074a56b8f373d3598dc36243091a4a45 (patch)
treeca18e4a7b770c9f38978d7e5103904d140238d11
parent3fc72ca8a819dec0da5506dce810238df86a8ae4 (diff)
[1.0.X] Fixed #9548 -- Correctly detect existence of empty sessions with cache backend.
Backport of r9934 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@9935 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/contrib/sessions/backends/cache.py2
-rw-r--r--django/contrib/sessions/tests.py5
2 files changed, 6 insertions, 1 deletions
diff --git a/django/contrib/sessions/backends/cache.py b/django/contrib/sessions/backends/cache.py
index 5fdf133b05..ab0716dcb4 100644
--- a/django/contrib/sessions/backends/cache.py
+++ b/django/contrib/sessions/backends/cache.py
@@ -43,7 +43,7 @@ class SessionStore(SessionBase):
raise CreateError
def exists(self, session_key):
- if self._cache.get(session_key):
+ if self._cache.has_key(session_key):
return True
return False
diff --git a/django/contrib/sessions/tests.py b/django/contrib/sessions/tests.py
index cf6922449f..18aa9eb261 100644
--- a/django/contrib/sessions/tests.py
+++ b/django/contrib/sessions/tests.py
@@ -156,6 +156,11 @@ False
False
>>> cache_session.items() == prev_data
True
+>>> cache_session = CacheSession()
+>>> cache_session.save()
+>>> key = cache_session.session_key
+>>> cache_session.exists(key)
+True
>>> Session.objects.filter(pk=cache_session.session_key).delete()
>>> cache_session = CacheSession(cache_session.session_key)