summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2008-08-16 15:54:36 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2008-08-16 15:54:36 +0000
commit54f9a987137d649899cfc65c87eb8baf8308dc09 (patch)
tree6472348922f79210e9281cf6fa1c88c92d5c7949
parent6bcb4935f290ed4caee9cbb0e99c3870d2cb5103 (diff)
Fixed #8351 -- Fixed the returned value when we attempt to load a cache-backed session object that doesn't alreayd exist.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8410 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/contrib/sessions/backends/cache.py1
-rw-r--r--django/contrib/sessions/tests.py4
2 files changed, 5 insertions, 0 deletions
diff --git a/django/contrib/sessions/backends/cache.py b/django/contrib/sessions/backends/cache.py
index dad5117ea3..94ae448a1f 100644
--- a/django/contrib/sessions/backends/cache.py
+++ b/django/contrib/sessions/backends/cache.py
@@ -14,6 +14,7 @@ class SessionStore(SessionBase):
if session_data is not None:
return session_data
self.create()
+ return {}
def create(self):
while True:
diff --git a/django/contrib/sessions/tests.py b/django/contrib/sessions/tests.py
index 9b88bed8d8..ffa32d6ae1 100644
--- a/django/contrib/sessions/tests.py
+++ b/django/contrib/sessions/tests.py
@@ -10,6 +10,7 @@ r"""
>>> db_session = DatabaseSession()
>>> db_session.modified
False
+>>> db_session.get('cat')
>>> db_session['cat'] = "dog"
>>> db_session.modified
True
@@ -42,6 +43,7 @@ False
>>> Session.objects.filter(pk=db_session.session_key).delete()
>>> db_session = DatabaseSession(db_session.session_key)
>>> db_session.save()
+>>> DatabaseSession('1').get('cat')
>>> file_session = FileSession()
>>> file_session.modified
@@ -59,6 +61,7 @@ True
>>> file_session.delete(file_session.session_key)
>>> file_session.exists(file_session.session_key)
False
+>>> FileSession('1').get('cat')
>>> file_session['foo'] = 'bar'
>>> file_session.save()
@@ -112,6 +115,7 @@ False
>>> Session.objects.filter(pk=cache_session.session_key).delete()
>>> cache_session = CacheSession(cache_session.session_key)
>>> cache_session.save()
+>>> CacheSession('1').get('cat')
>>> s = SessionBase()
>>> s._session['some key'] = 'exists' # Pre-populate the session with some data