Project

General

Profile

Download (387 Bytes) Statistics
| Branch: | Tag: | Revision:

calebasse / calebasse / middleware / request.py @ 0ae9ecd6

1
# -*- coding: utf-8 -*-
2
import threading
3

    
4
if not 'context' in locals():
5
    context = threading.local()
6

    
7
def _get_context():
8
    return context
9

    
10
def get_request():
11
    return getattr(_get_context(), 'request', None)
12

    
13
def set_request(request):
14
    _get_context().request=request
15

    
16
class GlobalRequestMiddleware(object):
17
    def process_request(self, request):
18
        set_request(request)
(2-2/2)