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:
Russell Keith-Magee 2007-09-11 14:04:40 +00:00
parent db01d1d0a8
commit 50497e3867
3 changed files with 5 additions and 8 deletions

View File

@ -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 ''

View File

@ -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:

View File

@ -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__()