Django

Code

Changeset 711

Show
Ignore:
Timestamp:
09/27/05 11:33:25 (3 years ago)
Author:
adrian
Message:

Fixed #567 -- Added HttpRequest.has_key() method. Thanks, wojtek3@brandlay.com

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/utils/httpwrappers.py

    r672 r711  
    2020                return d[key] 
    2121        raise KeyError, "%s not found in either POST or GET" % key 
     22 
     23    def has_key(self, key): 
     24        return self.GET.has_key(key) or self.POST.has_key(key) 
    2225 
    2326    def get_full_path(self): 
  • django/trunk/docs/request_response.txt

    r668 r711  
    110110Methods 
    111111------- 
     112 
     113``__getitem__(key)`` 
     114    Returns the GET/POST value for the given key, checking POST first, then 
     115    GET. Raises ``KeyError`` if the key doesn't exist. 
     116 
     117    This lets you use dictionary-accessing syntax on an ``HttpRequest`` 
     118    instance. Example: ``request["foo"]`` would return ``True`` if either 
     119    ``request.POST`` or ``request.GET`` had a ``"foo"`` key. 
     120 
     121``has_key()`` 
     122    Returns ``True`` or ``False``, designating whether ``request.GET`` or 
     123    ``request.POST`` has the given key. 
    112124 
    113125``get_full_path()``