From 54f9a987137d649899cfc65c87eb8baf8308dc09 Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Sat, 16 Aug 2008 15:54:36 +0000 Subject: [PATCH] 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 --- django/contrib/sessions/backends/cache.py | 1 + django/contrib/sessions/tests.py | 4 ++++ 2 files changed, 5 insertions(+) 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