summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2005-08-31 16:27:59 +0000
committerAdrian Holovaty <adrian@holovaty.com>2005-08-31 16:27:59 +0000
commitcb6aa1035bf900e9f124e91c0521f7081ba105e3 (patch)
tree99704a7a9e4d0b4713f7ef44c405e36e7d6ef797
parentabe7fb8173326567463d21257db73647d4a7b365 (diff)
Fixed #407 -- Code no longer assumes request.META['REMOTE_ADDR'] exists. Thanks, sune.kirkeby@gmail.com
git-svn-id: http://code.djangoproject.com/svn/django/trunk@580 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/contrib/comments/views/comments.py2
-rw-r--r--django/core/handlers/base.py4
-rw-r--r--django/core/xheaders.py2
-rw-r--r--django/middleware/doc.py2
4 files changed, 5 insertions, 5 deletions
diff --git a/django/contrib/comments/views/comments.py b/django/contrib/comments/views/comments.py
index 8798c05a01..324ba0f0c9 100644
--- a/django/contrib/comments/views/comments.py
+++ b/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,
diff --git a/django/core/handlers/base.py b/django/core/handlers/base.py
index c0e22dbb6a..00149ff791 100644
--- a/django/core/handlers/base.py
+++ b/django/core/handlers/base.py
@@ -79,7 +79,7 @@ class BaseHandler:
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 @@ class BaseHandler:
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:
diff --git a/django/core/xheaders.py b/django/core/xheaders.py
index 80210a25a0..98d2586b75 100644
--- a/django/core/xheaders.py
+++ b/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)
diff --git a/django/middleware/doc.py b/django/middleware/doc.py
index 8f648e0665..9345dbfcef 100644
--- a/django/middleware/doc.py
+++ b/django/middleware/doc.py
@@ -12,7 +12,7 @@ class XViewMiddleware:
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