Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Converted request.META['REQUEST_METHOD'] calls to request.method, thr…

…oughout the Django codebase

git-svn-id: http://code.djangoproject.com/svn/django/trunk@3171 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 37addba352b3443c30e6d6d862afe73e158839ca 1 parent b93de6a
@adrianholovaty adrianholovaty authored
View
2  django/core/handlers/wsgi.py
@@ -68,7 +68,7 @@ def get_full_path(self):
def _load_post_and_files(self):
# Populates self._post and self._files
- if self.environ['REQUEST_METHOD'] == 'POST':
+ if self.method == 'POST':
if self.environ.get('CONTENT_TYPE', '').startswith('multipart'):
header_dict = dict([(k, v) for k, v in self.environ.items() if k.startswith('HTTP_')])
header_dict['Content-Type'] = self.environ.get('CONTENT_TYPE', '')
View
4 django/middleware/cache.py
@@ -33,7 +33,7 @@ def __init__(self, cache_timeout=None, key_prefix=None):
def process_request(self, request):
"Checks whether the page is already cached and returns the cached version if available."
- if not request.META['REQUEST_METHOD'] in ('GET', 'HEAD') or request.GET:
+ if not request.method in ('GET', 'HEAD') or request.GET:
request._cache_update_cache = False
return None # Don't bother checking the cache.
@@ -55,7 +55,7 @@ def process_response(self, request, response):
if not hasattr(request, '_cache_update_cache') or not request._cache_update_cache:
# We don't need to update the cache, just return.
return response
- if not request.META['REQUEST_METHOD'] == 'GET':
+ if request.method != 'GET':
# This is a stronger requirement than above. It is needed
# because of interactions between this middleware and the
# HTTPMiddleware, which throws the body of a HEAD-request
View
2  django/middleware/common.py
@@ -39,7 +39,7 @@ def process_request(self, request):
# trailing slash or a file extension.
if settings.APPEND_SLASH and (old_url[1][-1] != '/') and ('.' not in old_url[1].split('/')[-1]):
new_url[1] = new_url[1] + '/'
- if settings.DEBUG and request.META['REQUEST_METHOD'].lower() == 'post':
+ if settings.DEBUG and request.method == 'POST':
raise RuntimeError, "You called this URL via POST, but the URL doesn't end in a slash and you have APPEND_SLASH set. Django can't redirect to the slash URL while maintaining POST data. Change your form to point to %s%s (note the trailing slash), or set APPEND_SLASH=False in your Django settings." % (new_url[0], new_url[1])
if new_url != old_url:
# Redirect
View
2  django/middleware/doc.py
@@ -11,7 +11,7 @@ def process_view(self, request, view_func, view_args, view_kwargs):
with an x-header indicating the view function. This is used by the
documentation module to lookup the view function for an arbitrary page.
"""
- if request.META['REQUEST_METHOD'] == 'HEAD' and request.META.get('REMOTE_ADDR') in settings.INTERNAL_IPS:
+ if request.method == 'HEAD' and request.META.get('REMOTE_ADDR') in settings.INTERNAL_IPS:
response = http.HttpResponse()
response['X-View'] = "%s.%s" % (view_func.__module__, view_func.__name__)
return response
View
2  django/middleware/http.py
@@ -31,7 +31,7 @@ def process_response(self, request, response):
response.content = ''
response['Content-Length'] = '0'
- if request.META['REQUEST_METHOD'] == 'HEAD':
+ if request.method == 'HEAD':
response.content = ''
return response
View
5 django/views/decorators/http.py
@@ -17,12 +17,11 @@ def my_view(request):
# I can assume now that only GET or POST requests make it this far
# ...
- Note that request methods ARE case sensitive.
+ Note that request methods should be in uppercase.
"""
def decorator(func):
def inner(request, *args, **kwargs):
- method = request.META.get("REQUEST_METHOD", None)
- if method not in request_method_list:
+ if request.method not in request_method_list:
return HttpResponseNotAllowed(request_method_list)
return func(request, *args, **kwargs)
return inner
View
4 django/views/generic/create_update.py
@@ -106,7 +106,7 @@ def update_object(request, model, object_id=None, slug=None,
if request.POST:
new_data = request.POST.copy()
- if model._meta.has_field_type(FileField):
+ if model._meta.has_field_type(FileField):
new_data.update(request.FILES)
errors = manipulator.get_validation_errors(new_data)
manipulator.do_html2python(new_data)
@@ -178,7 +178,7 @@ def delete_object(request, model, post_delete_redirect,
except ObjectDoesNotExist:
raise Http404, "No %s found for %s" % (model._meta.app_label, lookup_kwargs)
- if request.META['REQUEST_METHOD'] == 'POST':
+ if request.method == 'POST':
object.delete()
if not request.user.is_anonymous():
request.user.message_set.create(message="The %s was deleted." % model._meta.verbose_name)
Please sign in to comment.
Something went wrong with that request. Please try again.