Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
Adrian Holovaty authored November 30, 2005
3  django/utils/datastructures.py
@@ -81,6 +81,9 @@ def __setitem__(self, key, value):
81 81
     def __len__(self):
82 82
         return len(self.data)
83 83
 
  84
+    def __contains__(self, key):
  85
+        return self.data.has_key(key)
  86
+
84 87
     def get(self, key, default):
85 88
         "Returns the default value if the requested data doesn't exist"
86 89
         try:
8  docs/request_response.txt
@@ -31,11 +31,11 @@ All attributes except ``session`` should be considered read-only.
31 31
 
32 32
 ``GET``
33 33
     A dictionary-like object containing all given HTTP GET parameters. See the
34  
-    ``MultiValueDict`` documentation below.
  34
+    ``QueryDict`` documentation below.
35 35
 
36 36
 ``POST``
37 37
     A dictionary-like object containing all given HTTP POST parameters. See the
38  
-    ``MultiValueDict`` documentation below.
  38
+    ``QueryDict`` documentation below.
39 39
 
40 40
 ``REQUEST``
41 41
     For convenience, a dictionary-like object that searches ``POST`` first,
@@ -150,6 +150,10 @@ directly.
150 150
     * ``__setitem__(key, value)`` -- Sets the given key to ``[value]``
151 151
       (a Python list whose single element is ``value``).
152 152
 
  153
+    * ``__contains__(key)`` -- **New in Django development version.*** Returns
  154
+      ``True`` if the given key exists. This lets you do, e.g.,
  155
+      ``if "foo" in request.GET``.
  156
+
153 157
     * ``__len__()``
154 158
 
155 159
     * ``get(key, default)`` -- Uses the same logic as ``__getitem__()`` above,

0 notes on commit 674ac13

Please sign in to comment.
Something went wrong with that request. Please try again.