Files
goodtimes/accounts/utils.py

14 lines
289 B
Python
Raw Permalink Normal View History

2024-02-29 13:25:50 +05:30
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)