ó
­ā0_c           @   sZ   d  d l  m Z d  d l m Z d  d l m Z d d l m Z d e f d     YZ d S(	   i’’’’(   t   http(   t   settings(   t   MiddlewareMixini   (   t   get_view_namet   XViewMiddlewarec           B   s   e  Z d  Z d   Z RS(   s^   
    Adds an X-View header to internal HEAD requests -- used by the documentation system.
    c         C   s   t  | d  s4 t d t j d k r* d n d   | j d k r | j j d  t j k sv | j	 j
 r | j	 j r t j   } t |  | d <| Sd S(	   s)  
        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.
        t   users¬   The XView middleware requires authentication middleware to be installed. Edit your MIDDLEWARE%s setting to insert 'django.contrib.auth.middleware.AuthenticationMiddleware'.t   _CLASSESt    t   HEADt   REMOTE_ADDRs   X-ViewN(   t   hasattrt   AssertionErrorR   t
   MIDDLEWAREt   Nonet   methodt   METAt   gett   INTERNAL_IPSR   t	   is_activet   is_staffR    t   HttpResponseR   (   t   selft   requestt	   view_funct	   view_argst   view_kwargst   response(    (    sE   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admindocs/middleware.pyt   process_view   s    *(   t   __name__t
   __module__t   __doc__R   (    (    (    sE   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admindocs/middleware.pyR      s   N(	   t   djangoR    t   django.confR   t   django.utils.deprecationR   t   utilsR   R   (    (    (    sE   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admindocs/middleware.pyt   <module>   s   