3
™(ƒhC  ã               @   s8   d dl mZ d dlmZ d dlmZ G dd„ deƒZdS )é    )Úhttp)Úsettings)ÚMiddlewareMixinc               @   s   e Zd ZdZdd„ ZdS )ÚXViewMiddlewarez^
    Adds an X-View header to internal HEAD requests -- used by the documentation system.
    c             C   st   t |dƒs$tdtjdkrdnd ƒ‚|jdkrp|jjdƒtjksP|jj	rp|jj
rptjƒ }d|j|jf |d	< |S dS )
a)  
        If the request method is HEAD and either the IP is internal or the
        user is a logged-in staff member, quickly return with an x-header
        indicating the view function.  This is used by the documentation module
        to lookup the view function for an arbitrary page.
        Úuserz¬The XView middleware requires authentication middleware to be installed. Edit your MIDDLEWARE%s setting to insert 'django.contrib.auth.middleware.AuthenticationMiddleware'.NZ_CLASSESÚ ÚHEADZREMOTE_ADDRz%s.%szX-View)ÚhasattrÚAssertionErrorr   Z
MIDDLEWAREÚmethodZMETAÚgetZINTERNAL_IPSr   Z	is_activeZis_staffr   ZHttpResponseÚ
__module__Ú__name__)ÚselfÚrequestZ	view_funcZ	view_argsZview_kwargsÚresponse© r   úG/tmp/pip-install-q3hcpn_q/Django/django/contrib/admindocs/middleware.pyÚprocess_view
   s    zXViewMiddleware.process_viewN)r   r   Ú__qualname__Ú__doc__r   r   r   r   r   r      s   r   N)Zdjangor   Zdjango.confr   Zdjango.utils.deprecationr   r   r   r   r   r   Ú<module>   s   