Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #709 -- Added a __contains__ method to MultiValueDict. Thanks, …

…Brantley

git-svn-id: http://code.djangoproject.com/svn/django/trunk@1498 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 674ac13ca6cf99a902d75e2fad5748570b0aa913 1 parent e2e98af
@adrianholovaty adrianholovaty authored
Showing with 9 additions and 2 deletions.
  1. +3 −0  django/utils/datastructures.py
  2. +6 −2 docs/request_response.txt
View
3  django/utils/datastructures.py
@@ -81,6 +81,9 @@ def __setitem__(self, key, value):
def __len__(self):
return len(self.data)
+ def __contains__(self, key):
+ return self.data.has_key(key)
+
def get(self, key, default):
"Returns the default value if the requested data doesn't exist"
try:
View
8 docs/request_response.txt
@@ -31,11 +31,11 @@ All attributes except ``session`` should be considered read-only.
``GET``
A dictionary-like object containing all given HTTP GET parameters. See the
- ``MultiValueDict`` documentation below.
+ ``QueryDict`` documentation below.
``POST``
A dictionary-like object containing all given HTTP POST parameters. See the
- ``MultiValueDict`` documentation below.
+ ``QueryDict`` documentation below.
``REQUEST``
For convenience, a dictionary-like object that searches ``POST`` first,
@@ -150,6 +150,10 @@ directly.
* ``__setitem__(key, value)`` -- Sets the given key to ``[value]``
(a Python list whose single element is ``value``).
+ * ``__contains__(key)`` -- **New in Django development version.*** Returns
+ ``True`` if the given key exists. This lets you do, e.g.,
+ ``if "foo" in request.GET``.
+
* ``__len__()``
* ``get(key, default)`` -- Uses the same logic as ``__getitem__()`` above,
Please sign in to comment.
Something went wrong with that request. Please try again.