diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2007-09-11 14:04:40 +0000 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2007-09-11 14:04:40 +0000 |
| commit | 50497e3867564e68050d326b22dc41fe82d79dc0 (patch) | |
| tree | a9697a6516d3ad9d9ebf3517818e409151772654 | |
| parent | db01d1d0a8b1d584b025164988de8003c2d29d1c (diff) | |
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
| -rw-r--r-- | django/http/__init__.py | 5 | ||||
| -rw-r--r-- | django/template/context.py | 3 | ||||
| -rw-r--r-- | django/utils/datastructures.py | 5 |
3 files changed, 5 insertions, 8 deletions
diff --git a/django/http/__init__.py b/django/http/__init__.py index 0e1c2a0fbb..20818f138b 100644 --- a/django/http/__init__.py +++ b/django/http/__init__.py @@ -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 '' diff --git a/django/template/context.py b/django/template/context.py index 59650b05fe..51cd88b7e9 100644 --- a/django/template/context.py +++ b/django/template/context.py @@ -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: diff --git a/django/utils/datastructures.py b/django/utils/datastructures.py index 4b60d1d194..d96e45b9c8 100644 --- a/django/utils/datastructures.py +++ b/django/utils/datastructures.py @@ -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""" |
