Added shadows to windows, woooooo.
[philo.git] / philo / contrib / penfield / middleware.py
1 from django.http import HttpResponse
2 from django.utils.decorators import decorator_from_middleware
3 from philo.contrib.penfield.exceptions import HttpNotAcceptable
4
5
6 class HttpNotAcceptableMiddleware(object):
7         """Middleware to catch HttpNotAcceptable errors and return an Http406 response.
8         See RFC 2616."""
9         def process_exception(self, request, exception):
10                 if isinstance(exception, HttpNotAcceptable):
11                         return HttpResponse(status=406)
12
13
14 http_not_acceptable = decorator_from_middleware(HttpNotAcceptableMiddleware)