1. Adam Knight
  2. milton

Source

milton / middleware / RequestMiddleware.py

from threading import local

thread_local = local()
thread_local.request = None

class RequestMiddleware(object):
    
    def process_request(self, request):
        global thread_local
        thread_local.request = request

    @classmethod
    def current_request(cls):
        return thread_local.request