#16674: Django's WSGI Handler should report exceptions to the start_response()
callback
-------------------------------------+-------------------------------------
Reporter: jamesh | Owner: nobody
Type: | Status: new
Uncategorized | Component: Core (Other)
Milestone: | Severity: Normal
Version: SVN | Keywords:
Resolution: | Has patch: 1
Triage Stage: Design | Needs tests: 0
decision needed | Easy pickings: 0
Needs documentation: 0 |
Patch needs improvement: 0 |
UI/UX: 0 |
-------------------------------------+-------------------------------------
Changes (by aaugustin):
* stage: Unreviewed => Design decision needed
Comment:
The reference is here: http://www.python.org/dev/peps/pep-3333/#error-
handling
> If no output has been written when an exception occurs, the call to
start_response will return normally, and the application will return an
error body to be sent to the browser.
==> Since Django calls `start_response` only once, there hasn't been any
output at this point, so it's safe to pass `exc_info` when exceptions
occur. My understanding is that the server shouldn't trap such exceptions
and return a generic error page. I haven't tested if common WSGI
implementations are compliant, though.
> Some middleware may wish to provide additional exception handling
services, or intercept and replace application error messages. In such
cases, middleware may choose to not re-raise the exc_info supplied to
start_response, but instead raise a middleware-specific exception, or
simply return without an exception after storing the supplied arguments.
==> This is exactly what the OP is trying to achieve.
> These techniques will work as long as application authors:
> 1. Always provide exc_info when beginning an error response
> 2. Never trap errors raised by start_response when exc_info is being
provided
==> I think that's what Django should do.
I agree with Graham that the difficult problem is to obtain the exception,
especially if it's been caught and handled by the application.
However, I think it would be an interesting step towards WSGI compliance
to pass to `start_response` the `exc_info` of exceptions handled by
`handle_uncaught_exception`.
Marking as "DDN" until we decide how much we want to fix in the context of
this ticket.
--
Ticket URL: <https://code.djangoproject.com/ticket/16674#comment:6>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.