blob: 54267e328fd59c22cf8aad7893c9d3d656c2569a [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 Baker8b0a1992015-02-04 17:04:11 -08007 raise Exception("Please add 'core.middleware.GlobalRequestMiddleware' to <XOS_DIR>/planetstack/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