2013-03-07 07:33:51 +08:00
|
|
|
from django.http import HttpResponse, StreamingHttpResponse
|
2015-12-30 23:51:16 +08:00
|
|
|
from django.urls import reverse
|
2013-03-07 07:33:51 +08:00
|
|
|
|
2011-10-14 05:34:56 +08:00
|
|
|
from . import urlconf_inner
|
|
|
|
|
2009-11-16 09:58:00 +08:00
|
|
|
|
|
|
|
class ChangeURLconfMiddleware(object):
|
|
|
|
def process_request(self, request):
|
|
|
|
request.urlconf = urlconf_inner.__name__
|
2010-03-26 23:08:24 +08:00
|
|
|
|
2013-11-03 05:34:05 +08:00
|
|
|
|
2010-03-26 23:08:24 +08:00
|
|
|
class NullChangeURLconfMiddleware(object):
|
|
|
|
def process_request(self, request):
|
|
|
|
request.urlconf = None
|
2013-03-07 07:33:51 +08:00
|
|
|
|
2013-11-03 05:34:05 +08:00
|
|
|
|
2013-03-07 07:33:51 +08:00
|
|
|
class ReverseInnerInResponseMiddleware(object):
|
|
|
|
def process_response(self, *args, **kwargs):
|
|
|
|
return HttpResponse(reverse('inner'))
|
|
|
|
|
2013-11-03 05:34:05 +08:00
|
|
|
|
2013-03-07 07:33:51 +08:00
|
|
|
class ReverseOuterInResponseMiddleware(object):
|
|
|
|
def process_response(self, *args, **kwargs):
|
|
|
|
return HttpResponse(reverse('outer'))
|
|
|
|
|
2013-11-03 05:34:05 +08:00
|
|
|
|
2013-03-07 07:33:51 +08:00
|
|
|
class ReverseInnerInStreaming(object):
|
|
|
|
def process_view(self, *args, **kwargs):
|
|
|
|
def stream():
|
|
|
|
yield reverse('inner')
|
|
|
|
return StreamingHttpResponse(stream())
|
|
|
|
|
2013-11-03 05:34:05 +08:00
|
|
|
|
2013-03-07 07:33:51 +08:00
|
|
|
class ReverseOuterInStreaming(object):
|
|
|
|
def process_view(self, *args, **kwargs):
|
|
|
|
def stream():
|
|
|
|
yield reverse('outer')
|
|
|
|
return StreamingHttpResponse(stream())
|