| Total Complexity | 5 |
| Total Lines | 15 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | # coding=utf-8 |
||
| 21 | class RoughpageFallbackMiddleware(MiddlewareMixin): |
||
| 22 | def process_response(self, request, response): |
||
| 23 | if response.status_code != 404: |
||
| 24 | # Non 404 response should not be treated with this middleware |
||
| 25 | return response |
||
| 26 | try: |
||
| 27 | return roughpage(request, request.path_info) |
||
| 28 | # Return the original response if any errors happened. Because this |
||
| 29 | # is a middleware, we can't assume the errors will be caught elsewhere. |
||
| 30 | except Http404: |
||
| 31 | return response |
||
| 32 | except Exception: |
||
| 33 | if settings.DEBUG: |
||
| 34 | raise |
||
| 35 | return response |
||
| 36 |