Permalink
Browse files

[1.0.X] Fixed #9548 -- Correctly detect existence of empty sessions w…

…ith 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
  • Loading branch information...
1 parent 3fc72ca commit 4d2de7a3074a56b8f373d3598dc36243091a4a45 @malcolmt malcolmt committed Mar 1, 2009
Showing with 6 additions and 1 deletion.
  1. +1 −1 django/contrib/sessions/backends/cache.py
  2. +5 −0 django/contrib/sessions/tests.py
View
2 django/contrib/sessions/backends/cache.py
@@ -43,7 +43,7 @@ def save(self, must_create=False):
raise CreateError
def exists(self, session_key):
- if self._cache.get(session_key):
+ if self._cache.has_key(session_key):
return True
return False
View
5 django/contrib/sessions/tests.py
@@ -156,6 +156,11 @@
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)

0 comments on commit 4d2de7a

Please sign in to comment.