1 # -*- coding: utf-8 -*-
2 from threading import local
5 _thread_locals = local()
8 def get_current_request():
9 return getattr(_thread_locals, 'request', None)
12 class ThreadLocalMiddleware(object):
14 def process_request(request):
15 _thread_locals.request = request