2011-10-13 21:34:56 +00:00
|
|
|
from __future__ import absolute_import
|
|
|
|
|
2013-03-06 23:33:51 +00:00
|
|
|
from django.core.urlresolvers import reverse
|
|
|
|
from django.http import HttpResponse, StreamingHttpResponse
|
|
|
|
|
2011-10-13 21:34:56 +00:00
|
|
|
from . import urlconf_inner
|
|
|
|
|
2009-11-16 01:58:00 +00:00
|
|
|
|
|
|
|
class ChangeURLconfMiddleware(object):
|
|
|
|
def process_request(self, request):
|
|
|
|
request.urlconf = urlconf_inner.__name__
|
2010-03-26 15:08:24 +00:00
|
|
|
|
|
|
|
class NullChangeURLconfMiddleware(object):
|
|
|
|
def process_request(self, request):
|
|
|
|
request.urlconf = None
|
2013-03-06 23:33:51 +00:00
|
|
|
|
|
|
|
class ReverseInnerInResponseMiddleware(object):
|
|
|
|
def process_response(self, *args, **kwargs):
|
|
|
|
return HttpResponse(reverse('inner'))
|
|
|
|
|
|
|
|
class ReverseOuterInResponseMiddleware(object):
|
|
|
|
def process_response(self, *args, **kwargs):
|
|
|
|
return HttpResponse(reverse('outer'))
|
|
|
|
|
|
|
|
class ReverseInnerInStreaming(object):
|
|
|
|
def process_view(self, *args, **kwargs):
|
|
|
|
def stream():
|
|
|
|
yield reverse('inner')
|
|
|
|
return StreamingHttpResponse(stream())
|
|
|
|
|
|
|
|
class ReverseOuterInStreaming(object):
|
|
|
|
def process_view(self, *args, **kwargs):
|
|
|
|
def stream():
|
|
|
|
yield reverse('outer')
|
|
|
|
return StreamingHttpResponse(stream())
|