diff --git a/django/core/handlers/base.py b/django/core/handlers/base.py
index f144ce4..0ad0482 100644
|
a
|
b
|
|
| 1 | 1 | import sys |
| | 2 | from pprint import pformat |
| 2 | 3 | |
| 3 | 4 | from django import http |
| 4 | 5 | from django.core import signals |
| … |
… |
class BaseHandler(object):
|
| 170 | 171 | request_repr = repr(request) |
| 171 | 172 | except: |
| 172 | 173 | request_repr = "Request repr() unavailable" |
| 173 | | message = "%s\n\n%s" % (self._get_traceback(exc_info), request_repr) |
| | 174 | request_metadata = {} |
| | 175 | for (key, metadata_getter) in ( |
| | 176 | ('GET', lambda request: pformat(request.GET)), |
| | 177 | ('POST', lambda request: not request._post_parse_error and pformat(request.POST) or '(could not parse)'), |
| | 178 | ('COOKIES', lambda request: pformat(request.COOKIES)), |
| | 179 | ('META', lambda request: pformat(request.META))): |
| | 180 | try: |
| | 181 | request_metadata[key] = metadata_getter(request) |
| | 182 | except Exception, e: |
| | 183 | request_metadata[key] = '(could not parse)' |
| | 184 | message = "%s\n\nRequest: %s\n\nGET: %s\n\nPOST: %s\n\nCOOKIES: %s\n\nMETA: %s\n\n" % ( |
| | 185 | self._get_traceback(exc_info), |
| | 186 | request_repr, |
| | 187 | request_metadata['GET'], |
| | 188 | request_metadata['POST'], |
| | 189 | request_metadata['COOKIES'], |
| | 190 | request_metadata['META'], |
| | 191 | ) |
| 174 | 192 | mail_admins(subject, message, fail_silently=True) |
| 175 | 193 | # Return an HttpResponse that displays a friendly error message. |
| 176 | 194 | callback, param_dict = resolver.resolve500() |
diff --git a/django/core/handlers/modpython.py b/django/core/handlers/modpython.py
index b1e3e17..c66fda7 100644
|
a
|
b
|
|
| 1 | 1 | import os |
| 2 | | from pprint import pformat |
| 3 | 2 | |
| 4 | 3 | from django import http |
| 5 | 4 | from django.core import signals |
| … |
… |
class ModPythonRequest(http.HttpRequest):
|
| 37 | 36 | self.path_info = u'/' |
| 38 | 37 | self._post_parse_error = False |
| 39 | 38 | |
| 40 | | def __repr__(self): |
| 41 | | # Since this is called as part of error handling, we need to be very |
| 42 | | # robust against potentially malformed input. |
| 43 | | try: |
| 44 | | get = pformat(self.GET) |
| 45 | | except: |
| 46 | | get = '<could not parse>' |
| 47 | | if self._post_parse_error: |
| 48 | | post = '<could not parse>' |
| 49 | | else: |
| 50 | | try: |
| 51 | | post = pformat(self.POST) |
| 52 | | except: |
| 53 | | post = '<could not parse>' |
| 54 | | try: |
| 55 | | cookies = pformat(self.COOKIES) |
| 56 | | except: |
| 57 | | cookies = '<could not parse>' |
| 58 | | try: |
| 59 | | meta = pformat(self.META) |
| 60 | | except: |
| 61 | | meta = '<could not parse>' |
| 62 | | return smart_str(u'<ModPythonRequest\npath:%s,\nGET:%s,\nPOST:%s,\nCOOKIES:%s,\nMETA:%s>' % |
| 63 | | (self.path, unicode(get), unicode(post), |
| 64 | | unicode(cookies), unicode(meta))) |
| 65 | | |
| 66 | 39 | def get_full_path(self): |
| 67 | 40 | # RFC 3986 requires self._req.args to be in the ASCII range, but this |
| 68 | 41 | # doesn't always happen, so rather than crash, we defensively encode it. |
diff --git a/django/core/handlers/wsgi.py b/django/core/handlers/wsgi.py
index 927b098..646e313 100644
|
a
|
b
|
|
| 1 | 1 | from threading import Lock |
| 2 | | from pprint import pformat |
| 3 | 2 | try: |
| 4 | 3 | from cStringIO import StringIO |
| 5 | 4 | except ImportError: |
| … |
… |
class WSGIRequest(http.HttpRequest):
|
| 94 | 93 | self.method = environ['REQUEST_METHOD'].upper() |
| 95 | 94 | self._post_parse_error = False |
| 96 | 95 | |
| 97 | | def __repr__(self): |
| 98 | | # Since this is called as part of error handling, we need to be very |
| 99 | | # robust against potentially malformed input. |
| 100 | | try: |
| 101 | | get = pformat(self.GET) |
| 102 | | except: |
| 103 | | get = '<could not parse>' |
| 104 | | if self._post_parse_error: |
| 105 | | post = '<could not parse>' |
| 106 | | else: |
| 107 | | try: |
| 108 | | post = pformat(self.POST) |
| 109 | | except: |
| 110 | | post = '<could not parse>' |
| 111 | | try: |
| 112 | | cookies = pformat(self.COOKIES) |
| 113 | | except: |
| 114 | | cookies = '<could not parse>' |
| 115 | | try: |
| 116 | | meta = pformat(self.META) |
| 117 | | except: |
| 118 | | meta = '<could not parse>' |
| 119 | | return '<WSGIRequest\nGET:%s,\nPOST:%s,\nCOOKIES:%s,\nMETA:%s>' % \ |
| 120 | | (get, post, cookies, meta) |
| 121 | | |
| 122 | 96 | def get_full_path(self): |
| 123 | 97 | # RFC 3986 requires query string arguments to be in the ASCII range. |
| 124 | 98 | # Rather than crash if this doesn't happen, we encode defensively. |
diff --git a/django/http/__init__.py b/django/http/__init__.py
index 446659b..ce0c86b 100644
|
a
|
b
|
|
| 1 | 1 | import os |
| 2 | 2 | import re |
| 3 | 3 | from Cookie import BaseCookie, SimpleCookie, CookieError |
| 4 | | from pprint import pformat |
| 5 | 4 | from urllib import urlencode |
| 6 | 5 | from urlparse import urljoin |
| 7 | 6 | try: |
| … |
… |
class HttpRequest(object):
|
| 38 | 37 | self.method = None |
| 39 | 38 | |
| 40 | 39 | def __repr__(self): |
| 41 | | return '<HttpRequest\nGET:%s,\nPOST:%s,\nCOOKIES:%s,\nMETA:%s>' % \ |
| 42 | | (pformat(self.GET), pformat(self.POST), pformat(self.COOKIES), |
| 43 | | pformat(self.META)) |
| | 40 | try: |
| | 41 | full_path = self.get_full_path() |
| | 42 | except: |
| | 43 | full_path = "(could not parse path)" |
| | 44 | return smart_str(u'<%s: %s %s>' % (self.__class__.__name__, self.method, full_path)) |
| 44 | 45 | |
| 45 | 46 | def get_host(self): |
| 46 | 47 | """Returns the HTTP host using the environment or request headers.""" |