diff --git a/rhetoric/middleware.py b/rhetoric/middleware.py index c23af74..8f2f26b 100644 --- a/rhetoric/middleware.py +++ b/rhetoric/middleware.py @@ -1,9 +1,20 @@ +from django.http import HttpResponse from django.middleware.csrf import CsrfViewMiddleware from rhetoric.view import ViewCallback class CsrfProtectedViewDispatchMiddleware(CsrfViewMiddleware): + + def process_request(self, request): + # We assume here that CsrfViewMiddleware doesn't have the process_request method + # which should be called via super(). + # ------------------------------------------------- + # set request.response object as in + # http://docs.pylonsproject.org/projects/pyramid/en/latest/api/request.html#pyramid.request.Request.response + setattr(request, 'response', HttpResponse()) + + def process_view(self, request, callback, callback_args, callback_kwargs): if isinstance(callback, ViewCallback): view_settings = callback.find_view_settings(request, callback_args, callback_kwargs)