ó
®ā0_c           @   s   d  d l  Z  d  d l m Z d  d l m Z d  d l m Z 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’’’’N(   t   import_module(   t   settings(   t   UpdateError(   t   SuspiciousOperation(   t   patch_vary_headers(   t   MiddlewareMixin(   t   cookie_datet   SessionMiddlewarec           B   s&   e  Z d d   Z d   Z d   Z RS(   c         C   s(   | |  _  t t j  } | j |  _ d  S(   N(   t   get_responseR    R   t   SESSION_ENGINEt   SessionStore(   t   selfR   t   engine(    (    sD   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/sessions/middleware.pyt   __init__   s    	c         C   s+   | j  j t j  } |  j |  | _ d  S(   N(   t   COOKIESt   getR   t   SESSION_COOKIE_NAMER
   t   session(   R   t   requestt   session_key(    (    sD   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/sessions/middleware.pyt   process_request   s    c   	      C   s  y+ | j  j } | j  j } | j  j   } Wn t k
 r> nNXt j | j k r| | r| | j t j d t j	 d t j
 n| r t | d
  n  | s” t j r| r| j  j   rĘ d } d } n+ | j  j   } t j   | } t |  } | j d k ry | j  j   Wn t k
 r0t d   n X| j t j | j  j d | d | d t j
 d t j	 d t j psd d	 t j pd qn  | S(   så   
        If request.session was modified, or if the configuration is to save the
        session every time, save the changes and set a session cookie or delete
        the session cookie if the session has been emptied.
        t   patht   domaint   Cookieiō  s   The request's session was deleted before the request completed. The user may have logged out in a concurrent request, for example.t   max_aget   expirest   securet   httponly(   R   N(   R   t   accessedt   modifiedt   is_emptyt   AttributeErrorR   R   R   t   delete_cookiet   SESSION_COOKIE_PATHt   SESSION_COOKIE_DOMAINR   t   SESSION_SAVE_EVERY_REQUESTt   get_expire_at_browser_closet   Nonet   get_expiry_aget   timeR   t   status_codet   saveR   R   t
   set_cookieR   t   SESSION_COOKIE_SECUREt   SESSION_COOKIE_HTTPONLY(	   R   R   t   responseR   R   t   emptyR   R   t   expires_time(    (    sD   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/sessions/middleware.pyt   process_response   sD    				N(   t   __name__t
   __module__R%   R   R   R0   (    (    (    sD   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/sessions/middleware.pyR      s   	(   R'   t	   importlibR    t   django.confR   t%   django.contrib.sessions.backends.baseR   t   django.core.exceptionsR   t   django.utils.cacheR   t   django.utils.deprecationR   t   django.utils.httpR   R   (    (    (    sD   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/sessions/middleware.pyt   <module>   s   