blob: 951b993aff78456f8e69936692334662ad4a6e40 [file] [log] [blame]
showardff901382008-07-07 23:22:16 +00001import threading
2
showard2bab8f42008-11-12 18:15:22 +00003# when using the models from a script, use this object to avoid null checks all
4# over the place
5class NullUser(object):
6 def is_superuser(self):
7 return True
8
9
showardff901382008-07-07 23:22:16 +000010_store = threading.local()
showard2bab8f42008-11-12 18:15:22 +000011_store.user = NullUser()
showardff901382008-07-07 23:22:16 +000012
13def set_user(user):
14 """\
15 Sets the current request's logged-in user. user should be a
16 afe.models.User object.
17 """
18 _store.user = user
19
20
21def get_user():
22 'Get the currently logged-in user as a afe.models.User object.'
23 return _store.user