Django

Code

root/django/branches/newforms-admin/django/contrib/flatpages/middleware.py

Revision 4265, 0.7 kB (checked in by adrian, 2 years ago)

Fixed #3191 -- Set 'svn:eol-style native' on the files that didn't have it. Thanks, jjl@pobox.com

  • Property svn:eol-style set to native
Line 
1 from django.contrib.flatpages.views import flatpage
2 from django.http import Http404
3 from django.conf import settings
4
5 class FlatpageFallbackMiddleware(object):
6     def process_response(self, request, response):
7         if response.status_code != 404:
8             return response # No need to check for a flatpage for non-404 responses.
9         try:
10             return flatpage(request, request.path)
11         # Return the original response if any errors happened. Because this
12         # is a middleware, we can't assume the errors will be caught elsewhere.
13         except Http404:
14             return response
15         except:
16             if settings.DEBUG:
17                 raise
18             return response
Note: See TracBrowser for help on using the browser.