diff options
| author | Robin Munn <robin.munn@gmail.com> | 2006-09-25 15:39:20 +0000 |
|---|---|---|
| committer | Robin Munn <robin.munn@gmail.com> | 2006-09-25 15:39:20 +0000 |
| commit | 1bb4fa2cb66269b1eff3b7d73f8c7864c0622368 (patch) | |
| tree | 99ebf72b9983e35e50e65d0d421949a2740bf105 /django/core/handlers/modpython.py | |
| parent | 8afc419b123f315d724cbefdbc4c07f0982627a9 (diff) | |
sqlalchemy: Merged revisions 3770 to 3831 from trunk.
git-svn-id: http://code.djangoproject.com/svn/django/branches/sqlalchemy@3832 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/core/handlers/modpython.py')
| -rw-r--r-- | django/core/handlers/modpython.py | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/django/core/handlers/modpython.py b/django/core/handlers/modpython.py index 07c98e3b59..41d9a578c5 100644 --- a/django/core/handlers/modpython.py +++ b/django/core/handlers/modpython.py @@ -16,9 +16,26 @@ class ModPythonRequest(http.HttpRequest): self.path = req.uri def __repr__(self): + # Since this is called as part of error handling, we need to be very + # robust against potentially malformed input. + try: + get = pformat(self.GET) + except: + get = '<could not parse>' + try: + post = pformat(self.POST) + except: + post = '<could not parse>' + try: + cookies = pformat(self.COOKIES) + except: + cookies = '<could not parse>' + try: + meta = pformat(self.META) + except: + meta = '<could not parse>' return '<ModPythonRequest\npath:%s,\nGET:%s,\nPOST:%s,\nCOOKIES:%s,\nMETA:%s>' % \ - (self.path, pformat(self.GET), pformat(self.POST), pformat(self.COOKIES), - pformat(self.META)) + (self.path, get, post, cookies, meta) def get_full_path(self): return '%s%s' % (self.path, self._req.args and ('?' + self._req.args) or '') @@ -155,8 +172,11 @@ def populate_apache_request(http_response, mod_python_req): for c in http_response.cookies.values(): mod_python_req.headers_out.add('Set-Cookie', c.output(header='')) mod_python_req.status = http_response.status_code - for chunk in http_response.iterator: - mod_python_req.write(chunk) + try: + for chunk in http_response: + mod_python_req.write(chunk) + finally: + http_response.close() def handler(req): # mod_python hooks into this function. |
