Ticket #12098: requestrepr.diff

File requestrepr.diff, 3.3 KB (added by Cody Soyland <codysoyland@…>, 15 years ago)

Replaces output of request.repr with the method and URL

  • django/core/handlers/modpython.py

    diff --git a/django/core/handlers/modpython.py b/django/core/handlers/modpython.py
    index b1e3e17..5d7d78e 100644
    a b class ModPythonRequest(http.HttpRequest):  
    3838        self._post_parse_error = False
    3939
    4040    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)))
     41        return smart_str(u'<ModPythonRequest: %s %s>' % (self.method, self.get_full_path()))
    6542
    6643    def get_full_path(self):
    6744        # RFC 3986 requires self._req.args to be in the ASCII range, but this
  • django/core/handlers/wsgi.py

    diff --git a/django/core/handlers/wsgi.py b/django/core/handlers/wsgi.py
    index 927b098..3c8ab3b 100644
    a b class WSGIRequest(http.HttpRequest):  
    9595        self._post_parse_error = False
    9696
    9797    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)
     98        return '<WSGIRequest: %s %s>' % (self.method, self.get_full_path())
    12199
    122100    def get_full_path(self):
    123101        # RFC 3986 requires query string arguments to be in the ASCII range.
  • django/http/__init__.py

    diff --git a/django/http/__init__.py b/django/http/__init__.py
    index 683212f..6edf838 100644
    a b class HttpRequest(object):  
    3838        self.method = None
    3939
    4040    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))
     41        return '<HttpRequest: %s %s>' % (self.method, self.get_full_path())
    4442
    4543    def get_host(self):
    4644        """Returns the HTTP host using the environment or request headers."""
Back to Top