14 lines
289 B
Python
14 lines
289 B
Python
|
|
import threading
|
||
|
|
|
||
|
|
|
||
|
|
class UserContext:
|
||
|
|
_thread_local_data = threading.local()
|
||
|
|
|
||
|
|
@classmethod
|
||
|
|
def set_user(cls, user):
|
||
|
|
cls._thread_local_data.current_user = user
|
||
|
|
|
||
|
|
@classmethod
|
||
|
|
def get_user(cls):
|
||
|
|
return getattr(cls._thread_local_data, "current_user", None)
|