El 10/06/12 22:25, Daniel Swarbrick escribió:
I have a number of views that can raise a custom exception when
something unexpected happens (in this particular case, when a back end
server TCP socket connection fails). I'd like to use middleware to
catch this exception, inject an error message into request, and then
render the page as per normal (eg. as if the exception had not
occurred). Is middleware the right way to go about this, and can
somebody give me a few tips? I've used Django for over four years, but
in all that time have never written any custom middleware.
So far I've looked into using process_exception(), which was partially
successful, in that I can catch my custom exception there, but I'm not
sure how to then steer Django back onto the normal path of a
request/response. It seems that I can only return an error page from
there, which isn't quite what I want.
Thanks in advance.
--
You received this message because you are subscribed to the Google
Groups "Django users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/django-users/-/q996qhg1yYoJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.
Hi,
I really like how Horizon(Openstack Django based library) manages
exceptions, implementing a single handling method handling or
re-raising/delegating exceptions, finally managed by its own middleware.
Probably is much more than you need, but you might help you.
https://github.com/openstack/horizon/blob/master/horizon/exceptions.py#L227
https://github.com/openstack/horizon/blob/master/horizon/middleware.py#L64
HTH
--
You received this message because you are subscribed to the Google Groups "Django
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.