Added include_package_data option to setup.py to ensure MANIFEST.in is actually heeded.
[philo.git] / philo / contrib / winer / middleware.py
1 from django.http import HttpResponse
2 from django.utils.decorators import decorator_from_middleware
3
4 from philo.contrib.winer.exceptions import HttpNotAcceptable
5
6
7 class HttpNotAcceptableMiddleware(object):
8         """Middleware to catch :exc:`~philo.contrib.winer.exceptions.HttpNotAcceptable` and return an :class:`HttpResponse` with a 406 response code. 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)