Skip to content

Commit

Permalink
Fixed #1339 -- Added keys() and items() methods to session objects. T…
Browse files Browse the repository at this point in the history
…hanks, Ned Batchelder

git-svn-id: http://code.djangoproject.com/svn/django/trunk@2300 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
adrianholovaty committed Feb 10, 2006
1 parent d8b4d29 commit bf16bef
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Expand Up @@ -36,6 +36,7 @@ answer newbie questions, and generally made Django that much better:
David Ascher <http://ascher.ca/> David Ascher <http://ascher.ca/>
Arthur <avandorp@gmail.com> Arthur <avandorp@gmail.com>
Jiri Barton Jiri Barton
Ned Batchelder <http://www.nedbatchelder.com/>
James Bennett James Bennett
Paul Bissex <http://e-scribe.com/> Paul Bissex <http://e-scribe.com/>
Simon Blanchard Simon Blanchard
Expand Down
6 changes: 6 additions & 0 deletions django/middleware/sessions.py
Expand Up @@ -25,6 +25,12 @@ def __delitem__(self, key):
del self._session[key] del self._session[key]
self.modified = True self.modified = True


def keys(self):
return self._session.keys()

def items(self):
return self._session.items()

def get(self, key, default=None): def get(self, key, default=None):
return self._session.get(key, default) return self._session.get(key, default)


Expand Down
6 changes: 6 additions & 0 deletions docs/sessions.txt
Expand Up @@ -50,6 +50,12 @@ It implements the following standard dictionary methods:
* ``get(key, default=None)`` * ``get(key, default=None)``
Example: ``fav_color = request.session.get('fav_color', 'red')`` 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: It also has these three methods:


* ``set_test_cookie()`` * ``set_test_cookie()``
Expand Down

0 comments on commit bf16bef

Please sign in to comment.