Ticket #407: django.patch

File django.patch, 3.1 KB (added by sune.kirkeby@…, 19 years ago)

Patch

  • contrib/comments/views/comments.py

     
    204204    new_data = request.POST.copy()
    205205    new_data['content_type_id'] = content_type_id
    206206    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')
    208208    new_data['is_public'] = comments.IS_PUBLIC in option_list
    209209    response = HttpResponse()
    210210    manipulator = PublicCommentManipulator(request.user,
  • core/xheaders.py

     
    1717    within the INTERNAL_IPS setting.
    1818    """
    1919    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:
    2121        response['X-Object-Type'] = "%s.%s" % (package, python_module_name)
    2222        response['X-Object-Id'] = str(object_id)
  • core/handlers/base.py

     
    7979            if DEBUG:
    8080                return self.get_technical_error_response()
    8181            else:
    82                 subject = 'Database error (%s IP)' % (request.META['REMOTE_ADDR'] in INTERNAL_IPS and 'internal' or 'EXTERNAL')
     82                subject = 'Database error (%s IP)' % (request.META.get('REMOTE_ADDR', '[UNKNOWN]') in INTERNAL_IPS and 'internal' or 'EXTERNAL')
    8383                message = "%s\n\n%s" % (self._get_traceback(), request)
    8484                mail_admins(subject, message, fail_silently=True)
    8585                return self.get_friendly_error_response(request, resolver)
     
    8989            if DEBUG:
    9090                return self.get_technical_error_response()
    9191            else:
    92                 subject = 'Coding error (%s IP)' % (request.META['REMOTE_ADDR'] in INTERNAL_IPS and 'internal' or 'EXTERNAL')
     92                subject = 'Coding error (%s IP)' % (request.META.get('REMOTE_ADDR', '[UNKNOWN]') in INTERNAL_IPS and 'internal' or 'EXTERNAL')
    9393                try:
    9494                    request_repr = repr(request)
    9595                except:
  • middleware/doc.py

     
    1212        with an x-header indicating the view function.  This is used by the
    1313        documentation module to lookup the view function for an arbitrary page.
    1414        """
    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:
    1616            response = httpwrappers.HttpResponse()
    1717            response['X-View'] = "%s.%s" % (view_func.__module__, view_func.__name__)
    1818            return response
Back to Top