summaryrefslogtreecommitdiff
path: root/main/middleware.py
blob: db2c11046560e3429ebc09c1810f17a598ef0126 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import threading

user_holder = threading.local()
user_holder.user = None

# http://code.djangoproject.com/wiki/CookBookThreadlocalsAndUser
class AutoUserMiddleware(object):
    '''Saves the current user so it can be retrieved by the admin'''
    def process_request(self, request):
        user_holder.user = request.user


def get_user():
    '''Get the currently logged in request.user'''
    return user_holder.user