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