Fixed #567 -- Added HttpRequest.has_key() method. Thanks, wojtek3@brandlay.com
git-svn-id: http://code.djangoproject.com/svn/django/trunk@711 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
2d1303bd68
commit
8b67f5f829
|
@ -20,6 +20,9 @@ class HttpRequest(object): # needs to be new-style class because subclasses defi
|
||||||
return d[key]
|
return d[key]
|
||||||
raise KeyError, "%s not found in either POST or GET" % key
|
raise KeyError, "%s not found in either POST or GET" % key
|
||||||
|
|
||||||
|
def has_key(self, key):
|
||||||
|
return self.GET.has_key(key) or self.POST.has_key(key)
|
||||||
|
|
||||||
def get_full_path(self):
|
def get_full_path(self):
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
|
|
@ -110,6 +110,18 @@ All attributes except ``session`` should be considered read-only.
|
||||||
Methods
|
Methods
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
``__getitem__(key)``
|
||||||
|
Returns the GET/POST value for the given key, checking POST first, then
|
||||||
|
GET. Raises ``KeyError`` if the key doesn't exist.
|
||||||
|
|
||||||
|
This lets you use dictionary-accessing syntax on an ``HttpRequest``
|
||||||
|
instance. Example: ``request["foo"]`` would return ``True`` if either
|
||||||
|
``request.POST`` or ``request.GET`` had a ``"foo"`` key.
|
||||||
|
|
||||||
|
``has_key()``
|
||||||
|
Returns ``True`` or ``False``, designating whether ``request.GET`` or
|
||||||
|
``request.POST`` has the given key.
|
||||||
|
|
||||||
``get_full_path()``
|
``get_full_path()``
|
||||||
Returns the ``path``, plus an appended query string, if applicable.
|
Returns the ``path``, plus an appended query string, if applicable.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue