blob: 4cfd9914520bd17a402c118831b925bdf9db3490 [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"):
Scott Baker76a840e2015-02-11 21:38:09 -08007 raise Exception("Please add 'core.middleware.GlobalRequestMiddleware' to <XOS_DIR>/xos.settings.py:MIDDLEWARE_CLASSES")
Scott Baker6810db22014-08-26 17:40:36 -07008 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