Refs #5138 -- Refactored implementation of __contains__ in HttpRequest introduced in [6097] after a suggestion from Malcolm. Applied a similar refactor for MergeDict and Context which had comparable behavior.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@6098 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
db01d1d0a8
commit
50497e3867
|
@ -38,11 +38,10 @@ class HttpRequest(object):
|
|||
return d[key]
|
||||
raise KeyError, "%s not found in either POST or GET" % key
|
||||
|
||||
def __contains__(self, key):
|
||||
def has_key(self, key):
|
||||
return key in self.GET or key in self.POST
|
||||
|
||||
def has_key(self, key):
|
||||
return key in self
|
||||
__contains__ = has_key
|
||||
|
||||
def get_full_path(self):
|
||||
return ''
|
||||
|
|
|
@ -49,8 +49,7 @@ class Context(object):
|
|||
return True
|
||||
return False
|
||||
|
||||
def __contains__(self, key):
|
||||
return self.has_key(key)
|
||||
__contains__ = has_key
|
||||
|
||||
def get(self, key, otherwise=None):
|
||||
for d in self.dicts:
|
||||
|
|
|
@ -14,9 +14,6 @@ class MergeDict(object):
|
|||
pass
|
||||
raise KeyError
|
||||
|
||||
def __contains__(self, key):
|
||||
return self.has_key(key)
|
||||
|
||||
def __copy__(self):
|
||||
return self.__class__(*self.dicts)
|
||||
|
||||
|
@ -45,6 +42,8 @@ class MergeDict(object):
|
|||
if key in dict:
|
||||
return True
|
||||
return False
|
||||
|
||||
__contains__ = has_key
|
||||
|
||||
def copy(self):
|
||||
""" returns a copy of this object"""
|
||||
|
|
Loading…
Reference in New Issue