Skip to content

Commit

Permalink
Add request.response object
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxim Avanov committed Jan 8, 2014
1 parent 5e12d54 commit 78aee47
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions rhetoric/middleware.py
Original file line number Diff line number Diff line change
@@ -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)
Expand Down

0 comments on commit 78aee47

Please sign in to comment.