Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
Adrian Holovaty authored August 31, 2005
2  django/contrib/comments/views/comments.py
@@ -204,7 +204,7 @@ def post_comment(request):
204 204
     new_data = request.POST.copy()
205 205
     new_data['content_type_id'] = content_type_id
206 206
     new_data['object_id'] = object_id
207  
-    new_data['ip_address'] = request.META['REMOTE_ADDR']
  207
+    new_data['ip_address'] = request.META.get('REMOTE_ADDR')
208 208
     new_data['is_public'] = comments.IS_PUBLIC in option_list
209 209
     response = HttpResponse()
210 210
     manipulator = PublicCommentManipulator(request.user,
4  django/core/handlers/base.py
@@ -79,7 +79,7 @@ def get_response(self, path, request):
79 79
             if DEBUG:
80 80
                 return self.get_technical_error_response()
81 81
             else:
82  
-                subject = 'Database error (%s IP): %s' % ((request.META['REMOTE_ADDR'] in INTERNAL_IPS and 'internal' or 'EXTERNAL'), getattr(request, 'path', ''))
  82
+                subject = 'Database error (%s IP): %s' % ((request.META.get('REMOTE_ADDR') in INTERNAL_IPS and 'internal' or 'EXTERNAL'), getattr(request, 'path', ''))
83 83
                 message = "%s\n\n%s" % (self._get_traceback(), request)
84 84
                 mail_admins(subject, message, fail_silently=True)
85 85
                 return self.get_friendly_error_response(request, resolver)
@@ -89,7 +89,7 @@ def get_response(self, path, request):
89 89
             if DEBUG:
90 90
                 return self.get_technical_error_response()
91 91
             else:
92  
-                subject = 'Coding error (%s IP): %s' % ((request.META['REMOTE_ADDR'] in INTERNAL_IPS and 'internal' or 'EXTERNAL'), getattr(request, 'path', ''))
  92
+                subject = 'Coding error (%s IP): %s' % ((request.META.get('REMOTE_ADDR') in INTERNAL_IPS and 'internal' or 'EXTERNAL'), getattr(request, 'path', ''))
93 93
                 try:
94 94
                     request_repr = repr(request)
95 95
                 except:
2  django/core/xheaders.py
@@ -17,6 +17,6 @@ def populate_xheaders(request, response, package, python_module_name, object_id)
17 17
     within the INTERNAL_IPS setting.
18 18
     """
19 19
     from django.conf.settings import INTERNAL_IPS
20  
-    if request.META['REMOTE_ADDR'] in INTERNAL_IPS:
  20
+    if request.META.get('REMOTE_ADDR') in INTERNAL_IPS:
21 21
         response['X-Object-Type'] = "%s.%s" % (package, python_module_name)
22 22
         response['X-Object-Id'] = str(object_id)
2  django/middleware/doc.py
@@ -12,7 +12,7 @@ def process_view(self, request, view_func, param_dict):
12 12
         with an x-header indicating the view function.  This is used by the
13 13
         documentation module to lookup the view function for an arbitrary page.
14 14
         """
15  
-        if request.META['REQUEST_METHOD'] == 'HEAD' and request.META['REMOTE_ADDR'] in settings.INTERNAL_IPS:
  15
+        if request.META['REQUEST_METHOD'] == 'HEAD' and request.META.get('REMOTE_ADDR') in settings.INTERNAL_IPS:
16 16
             response = httpwrappers.HttpResponse()
17 17
             response['X-View'] = "%s.%s" % (view_func.__module__, view_func.__name__)
18 18
             return response

0 notes on commit cb6aa10

Please sign in to comment.
Something went wrong with that request. Please try again.