a
    ùÜEbD  ã                   @   sL   d dl Z d dlmZ d dlmZ eƒ Ze  e¡Zdd„ Z	dd„ Z
dd	„ ZdS )
é    N)Úlocal)ÚAnonymousUserc                 C   s   t  d¡ ttd| ƒS )zj
    Binds the request to the current thread.

    :param request: Django request object
    :return:
    zSave request in current threadÚ(__django_userforeignkey__current_request)ÚloggerÚdebugÚsetattrÚ_thread_locals©Úrequest© r   ú]/home/ja/django-apps/lartica_env/lib/python3.9/site-packages/django_userforeignkey/request.pyÚset_current_request   s    
r   c                   C   s   t tddƒS )zW
    Gets the request from the current thread.

    :return: Django request object
    r   N)Úgetattrr   r   r   r   r   Úget_current_request   s    r   c                  C   s    t ƒ } | rt| dƒstƒ S | jS )zÞ
    Gets the current user from the current request. In case there is no current
    request, or there is no user information attached to the request, an AnonymousUser object
    is returned.

    :return: User object
    Úuser)r   Úhasattrr   r   r	   r   r   r   Úget_current_user    s    r   )ÚloggingÚ	threadingr   Zdjango.contrib.auth.modelsr   r   Ú	getLoggerÚ__name__r   r   r   r   r   r   r   r   Ú<module>   s   
	