magic-removal: Fixed #1445 -- Moved response middleware-handling code inside try/finally that closes DB connection

git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2474 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2006-03-02 14:34:37 +00:00
parent fd3de3e29e
commit 85f7fba723
2 changed files with 10 additions and 8 deletions

View File

@ -136,13 +136,14 @@ class ModPythonHandler(BaseHandler):
try:
request = ModPythonRequest(req)
response = self.get_response(req.uri, request)
# Apply response middleware
for middleware_method in self._response_middleware:
response = middleware_method(request, response)
finally:
dispatcher.send(signal=signals.request_finished)
# Apply response middleware
for middleware_method in self._response_middleware:
response = middleware_method(request, response)
# Convert our custom HttpResponse object back into the mod_python req.
populate_apache_request(response, req)
return 0 # mod_python.apache.OK

View File

@ -152,13 +152,14 @@ class WSGIHandler(BaseHandler):
try:
request = WSGIRequest(environ)
response = self.get_response(request.path, request)
# Apply response middleware
for middleware_method in self._response_middleware:
response = middleware_method(request, response)
finally:
dispatcher.send(signal=signals.request_finished)
# Apply response middleware
for middleware_method in self._response_middleware:
response = middleware_method(request, response)
try:
status_text = STATUS_CODE_TEXT[response.status_code]
except KeyError: