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]
|
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 __contains__(self, key):
|
def has_key(self, key):
|
||||||
return key in self.GET or key in self.POST
|
return key in self.GET or key in self.POST
|
||||||
|
|
||||||
def has_key(self, key):
|
__contains__ = has_key
|
||||||
return key in self
|
|
||||||
|
|
||||||
def get_full_path(self):
|
def get_full_path(self):
|
||||||
return ''
|
return ''
|
||||||
|
|
|
@ -49,8 +49,7 @@ class Context(object):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def __contains__(self, key):
|
__contains__ = has_key
|
||||||
return self.has_key(key)
|
|
||||||
|
|
||||||
def get(self, key, otherwise=None):
|
def get(self, key, otherwise=None):
|
||||||
for d in self.dicts:
|
for d in self.dicts:
|
||||||
|
|
|
@ -14,9 +14,6 @@ class MergeDict(object):
|
||||||
pass
|
pass
|
||||||
raise KeyError
|
raise KeyError
|
||||||
|
|
||||||
def __contains__(self, key):
|
|
||||||
return self.has_key(key)
|
|
||||||
|
|
||||||
def __copy__(self):
|
def __copy__(self):
|
||||||
return self.__class__(*self.dicts)
|
return self.__class__(*self.dicts)
|
||||||
|
|
||||||
|
@ -46,6 +43,8 @@ class MergeDict(object):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
__contains__ = has_key
|
||||||
|
|
||||||
def copy(self):
|
def copy(self):
|
||||||
""" returns a copy of this object"""
|
""" returns a copy of this object"""
|
||||||
return self.__copy__()
|
return self.__copy__()
|
||||||
|
|
Loading…
Reference in New Issue