2 View-specific utilities.
5 from .. import app_settings
6 from django.http import HttpResponse, HttpResponseRedirect
10 """Serves an URL either though Nginx's X-accel, or by redirection."""
11 if app_settings.XACCEL:
12 response = HttpResponse()
13 response['Content-Type'] = ""
14 response['X-Accel-Redirect'] = url
17 return HttpResponseRedirect(url)
20 def set_current_object(request, obj, in_url=True):
21 request.CURRENT_OBJECT = obj
22 request.CURRENT_OBJECT_IN_URL = in_url
25 def get_current_object(request, for_url=False):
26 if for_url and not getattr(request, 'CURRENT_OBJECT_IN_URL', True):
28 return getattr(request, 'CURRENT_OBJECT', None)