From bf16befc433ff9e1764db0fa57ef05b507eee0e0 Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Fri, 10 Feb 2006 21:33:07 +0000 Subject: [PATCH] Fixed #1339 -- Added keys() and items() methods to session objects. Thanks, Ned Batchelder git-svn-id: http://code.djangoproject.com/svn/django/trunk@2300 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- AUTHORS | 1 + django/middleware/sessions.py | 6 ++++++ docs/sessions.txt | 6 ++++++ 3 files changed, 13 insertions(+) diff --git a/AUTHORS b/AUTHORS index e9316b700d..b896f22e6b 100644 --- a/AUTHORS +++ b/AUTHORS @@ -36,6 +36,7 @@ answer newbie questions, and generally made Django that much better: David Ascher Arthur Jiri Barton + Ned Batchelder James Bennett Paul Bissex Simon Blanchard diff --git a/django/middleware/sessions.py b/django/middleware/sessions.py index d6d25de276..e6fa7d742d 100644 --- a/django/middleware/sessions.py +++ b/django/middleware/sessions.py @@ -25,6 +25,12 @@ class SessionWrapper(object): del self._session[key] self.modified = True + def keys(self): + return self._session.keys() + + def items(self): + return self._session.items() + def get(self, key, default=None): return self._session.get(key, default) diff --git a/docs/sessions.txt b/docs/sessions.txt index d3d1873a9a..6a208a1461 100644 --- a/docs/sessions.txt +++ b/docs/sessions.txt @@ -50,6 +50,12 @@ It implements the following standard dictionary methods: * ``get(key, default=None)`` Example: ``fav_color = request.session.get('fav_color', 'red')`` + * ``keys()`` + **New in Django development version.** + + * ``items()`` + **New in Django development version.** + It also has these three methods: * ``set_test_cookie()``