diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2007-04-26 13:30:48 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2007-04-26 13:30:48 +0000 |
| commit | 439cb4047fb583d08149f28e2ce66a8edfe0efa7 (patch) | |
| tree | 47ef30e70bf1d757f08b133d3aa47704db13c714 /django/http | |
| parent | 6c02565e4fb92c4cc3bfb45bcc89eb9aa299efdc (diff) | |
Fixed #4040 -- Changed uses of has_key() to "in". Slight performance
improvement and forward-compatible with future Python releases. Patch from Gary
Wilson.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5091 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/http')
| -rw-r--r-- | django/http/__init__.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/django/http/__init__.py b/django/http/__init__.py index ed2c128a16..a0c51ff0da 100644 --- a/django/http/__init__.py +++ b/django/http/__init__.py @@ -29,12 +29,12 @@ class HttpRequest(object): def __getitem__(self, key): for d in (self.POST, self.GET): - if d.has_key(key): + if key in d: return d[key] raise KeyError, "%s not found in either POST or GET" % key def has_key(self, key): - return self.GET.has_key(key) or self.POST.has_key(key) + return key in self.GET or key in self.POST def get_full_path(self): return '' @@ -57,7 +57,7 @@ def parse_file_upload(header_dict, post_data): # name_dict is something like {'name': 'file', 'filename': 'test.txt'} for file uploads # or {'name': 'blah'} for POST fields # We assume all uploaded files have a 'filename' set. - if name_dict.has_key('filename'): + if 'filename' in name_dict: assert type([]) != type(submessage.get_payload()), "Nested MIME messages are not supported" if not name_dict['filename'].strip(): continue @@ -66,7 +66,7 @@ def parse_file_upload(header_dict, post_data): filename = name_dict['filename'][name_dict['filename'].rfind("\\")+1:] FILES.appendlist(name_dict['name'], { 'filename': filename, - 'content-type': (submessage.has_key('Content-Type') and submessage['Content-Type'] or None), + 'content-type': 'Content-Type' in submessage and submessage['Content-Type'] or None, 'content': submessage.get_payload(), }) else: |
