blob: 1401cd673235426723b01ca1e7fc6d104de8d301 [file] [log] [blame]
Scott Baker6810db22014-08-26 17:40:36 -07001from threading import local
2
3_active = local()
4
5def get_request():
6 if not hasattr(_active, "request"):
7 raise Exception("Please add 'core.middleware.GlobalRequestMiddleware' to /opt/planetstack/planetstack/settings.py:MIDDLEWARE_CLASSES")
8 return _active.request
9
10class GlobalRequestMiddleware(object):
11 def process_view(self, request, view_func, view_args, view_kwargs):
12 _active.request = request
13 return None