~brunobord/django-fatpages/django-fatpages-0.96

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# This file is part of the Django-fatpages project, and thus being
# redistributed under the same terms, ie.: the GPL v3 license.
# See LICENSE files for more details

from views import fatpage
from django.http import Http404
from django.conf import settings

class FatpageFallbackMiddleware(object):
    def process_response(self, request, response):
        if response.status_code != 404:
            return response
        try:
            return fatpage(request, request.path)
        except Http404:
            return response
        except:
            if settings.DEBUG:
                raise
            return response