U
    dw                     @   s(   G d d dZ G dd dZdd ZdS )c                   @   s4   e Zd Zdd Zdd Zdd Zdd Zd	d
 ZdS )PermLookupDictc                 C   s   || | _ | _d S N)user	app_label)selfr   r    r   J/tmp/pip-unpacked-wheel-7vj2equ7/django/contrib/auth/context_processors.py__init__   s    zPermLookupDict.__init__c                 C   s   t | j S r   )strr   Zget_all_permissionsr   r   r   r   __repr__	   s    zPermLookupDict.__repr__c                 C   s   | j d| j|f S )Nz%s.%s)r   Zhas_permr   )r   	perm_namer   r   r   __getitem__   s    zPermLookupDict.__getitem__c                 C   s   t dd S )NzPermLookupDict is not iterable.	TypeErrorr
   r   r   r   __iter__   s    zPermLookupDict.__iter__c                 C   s   | j | jS r   )r   Zhas_module_permsr   r
   r   r   r   __bool__   s    zPermLookupDict.__bool__N)__name__
__module____qualname__r   r   r   r   r   r   r   r   r   r      s
   r   c                   @   s4   e Zd Zdd Zdd Zdd Zdd Zd	d
 ZdS )PermWrapperc                 C   s
   || _ d S r   )r   )r   r   r   r   r   r      s    zPermWrapper.__init__c                 C   s   | j j d| jdS )N())	__class__r   r   r
   r   r   r   r      s    zPermWrapper.__repr__c                 C   s   t | j|S r   )r   r   )r   r   r   r   r   r      s    zPermWrapper.__getitem__c                 C   s   t dd S )NzPermWrapper is not iterable.r   r
   r   r   r   r   "   s    zPermWrapper.__iter__c                 C   s0   d|krt | | S |dd\}}| | | S )zE
        Lookup by "someapp" or "someapp.someperm" in perms.
        .   )boolsplit)r   r   r   r   r   r   __contains__&   s    zPermWrapper.__contains__N)r   r   r   r   r   r   r   r   r   r   r   r   r      s
   r   c                 C   s2   t | dr| j}nddlm} | }|t|dS )z
    Return context variables required by apps that use Django's authentication
    system.

    If there is no 'user' attribute in the request, use AnonymousUser (from
    django.contrib.auth).
    r       )AnonymousUser)r   Zperms)hasattrr   Zdjango.contrib.auth.modelsr   r   )requestr   r   r   r   r   auth1   s    
r"   N)r   r   r"   r   r   r   r   <module>   s   