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
This commit is contained in:
parent
e2e98aff6a
commit
674ac13ca6
|
@ -81,6 +81,9 @@ class MultiValueDict:
|
|||
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:
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue