#12250: process_view middleware prevents process_exception handling
-------------------------------------+-------------------------------------
Reporter: manfre | Owner: manfre
Type: Bug | Status: new
Component: Core (Other) | Version: master
Severity: Normal | Resolution:
Keywords: middleware | Triage Stage: Design
Has patch: 1 | decision needed
Needs tests: 0 | Needs documentation: 0
Easy pickings: 0 | Patch needs improvement: 0
| UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by wdoekes):
* cc: wdoekes (added)
Comment:
{{{
126 + """
127 + A <Middleware>.process_view() that generates an exception
and another
128 + middleware whose process_exception() provides a response.
Result should
129 + be that response.
130 + """
131 + settings.MIDDLEWARE_CLASSES = (
132 +
'regressiontests.base_handler.middleware.ProcessViewRaise',
133 +
'regressiontests.base_handler.middleware.ProcessExceptionResponse',
134 + )
}}}
Well, I have a common scenario that would benefit from having the
exception handler handle the process_view() exception:
django/middleware/csrf.py
calls
{{{
request_csrf_token = request.POST.get('csrfmiddlewaretoken', '')
...
self._load_post_and_files()
...
return self._stream.read(*args, **kwargs)
IOError: error reading wsgi.input data
}}}
I'd love to ignore that particular IOError, and I can, when it's generated
in the view. But I can't when it's generated in the CSRF process_view.
As for how: I'd expect it to be handled just as if it was an exception in
the view itself. I.e. surround the _view_middleware calls with a
try/except just like the "response = callback(...)" bit.
Regards,
Walter Doekes
--
Ticket URL: <https://code.djangoproject.com/ticket/12250#comment:11>
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 https://groups.google.com/groups/opt_out.