def wrap_view(self, view):
        @csrf_exempt
        def wrapper(request, *args, **kwargs):
            try:
                callback = getattr(self, view)
                response = callback(request, *args, **kwargs)

                if request.is_ajax():
                    # IE excessively caches XMLHttpRequests, so we're disabling
                    # the browser cache here.
                    # See http://www.enhanceie.com/ie/bugs.asp for details.
                    patch_cache_control(response, no_cache=True)

                return response
            except (BadRequest, fields.ApiFieldError, ValidationError), e:
                return self.bad_request(request, e)
            except Exception, e:
                return self.handle_500(request, e)

        return wrapper
Wraps methods so they can be called in a more functional way as well
dataset/ETHPy150Open toastdriven/piecrust/piecrust/resources.py/Resource.wrap_view