î

_ÝV®  ã               @   s:   d  d l  m Z d  d l m Z Gd d „  d e ƒ Z d S)é    )Úhttp)Úsettingsc               @   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   s‹   t  | d ƒ s t d ƒ ‚ | j d k r‡ | j j d ƒ t j k s] | j j r‡ | j j	 r‡ t
 j ƒ  } d | j | j f | d <| Sd 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_CLASSES setting to insert 'django.contrib.auth.middleware.AuthenticationMiddleware'.ÚHEADZREMOTE_ADDRz%s.%szX-ViewN)ÚhasattrÚAssertionErrorÚmethodZMETAÚgetr   ZINTERNAL_IPSr   Z	is_activeZis_staffr   ZHttpResponseÚ
__module__Ú__name__)ÚselfÚrequestZ	view_funcZ	view_argsZview_kwargsÚresponse© r   úE/tmp/pip-build-ghmbqnp_/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   Úobjectr   r   r   r   r   Ú<module>   s   