Funktionierender Prototyp des Serious Games zur Vermittlung von Wissen zu Software-Engineering-Arbeitsmodellen.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

middleware.py 784B

1234567891011121314151617181920
  1. from django.conf import settings
  2. from django.contrib.flatpages.views import flatpage
  3. from django.http import Http404
  4. from django.utils.deprecation import MiddlewareMixin
  5. class FlatpageFallbackMiddleware(MiddlewareMixin):
  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_info)
  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 Exception:
  16. if settings.DEBUG:
  17. raise
  18. return response