Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #407 -- Code no longer assumes request.META['REMOTE_ADDR'] exis…

…ts. Thanks, sune.kirkeby@gmail.com

git-svn-id: http://code.djangoproject.com/svn/django/trunk@580 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit cb6aa1035bf900e9f124e91c0521f7081ba105e3 1 parent abe7fb8
@adrianholovaty adrianholovaty authored
View
2  django/contrib/comments/views/comments.py
@@ -204,7 +204,7 @@ def post_comment(request):
new_data = request.POST.copy()
new_data['content_type_id'] = content_type_id
new_data['object_id'] = object_id
- new_data['ip_address'] = request.META['REMOTE_ADDR']
+ new_data['ip_address'] = request.META.get('REMOTE_ADDR')
new_data['is_public'] = comments.IS_PUBLIC in option_list
response = HttpResponse()
manipulator = PublicCommentManipulator(request.user,
View
4 django/core/handlers/base.py
@@ -79,7 +79,7 @@ def get_response(self, path, request):
if DEBUG:
return self.get_technical_error_response()
else:
- subject = 'Database error (%s IP): %s' % ((request.META['REMOTE_ADDR'] in INTERNAL_IPS and 'internal' or 'EXTERNAL'), getattr(request, 'path', ''))
+ subject = 'Database error (%s IP): %s' % ((request.META.get('REMOTE_ADDR') in INTERNAL_IPS and 'internal' or 'EXTERNAL'), getattr(request, 'path', ''))
message = "%s\n\n%s" % (self._get_traceback(), request)
mail_admins(subject, message, fail_silently=True)
return self.get_friendly_error_response(request, resolver)
@@ -89,7 +89,7 @@ def get_response(self, path, request):
if DEBUG:
return self.get_technical_error_response()
else:
- subject = 'Coding error (%s IP): %s' % ((request.META['REMOTE_ADDR'] in INTERNAL_IPS and 'internal' or 'EXTERNAL'), getattr(request, 'path', ''))
+ subject = 'Coding error (%s IP): %s' % ((request.META.get('REMOTE_ADDR') in INTERNAL_IPS and 'internal' or 'EXTERNAL'), getattr(request, 'path', ''))
try:
request_repr = repr(request)
except:
View
2  django/core/xheaders.py
@@ -17,6 +17,6 @@ def populate_xheaders(request, response, package, python_module_name, object_id)
within the INTERNAL_IPS setting.
"""
from django.conf.settings import INTERNAL_IPS
- if request.META['REMOTE_ADDR'] in INTERNAL_IPS:
+ if request.META.get('REMOTE_ADDR') in INTERNAL_IPS:
response['X-Object-Type'] = "%s.%s" % (package, python_module_name)
response['X-Object-Id'] = str(object_id)
View
2  django/middleware/doc.py
@@ -12,7 +12,7 @@ def process_view(self, request, view_func, param_dict):
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['REMOTE_ADDR'] in settings.INTERNAL_IPS:
+ if request.META['REQUEST_METHOD'] == 'HEAD' and request.META.get('REMOTE_ADDR') in settings.INTERNAL_IPS:
response = httpwrappers.HttpResponse()
response['X-View'] = "%s.%s" % (view_func.__module__, view_func.__name__)
return response
Please sign in to comment.
Something went wrong with that request. Please try again.