î
ªÍ X…  ã               @   sJ   d  d l  m Z d  d l m Z d  d l m Z Gd d „  d e ƒ Z d S)é    )Úsettings)ÚSessionBase)Úsigningc               @   s   e  Z d  Z d d „  Z d d „  Z d d d „ Z d d	 d
 „ Z d d d „ Z d d „  Z d d „  Z	 e
 d d „  ƒ Z d S)ÚSessionStorec             C   sO   y, t  j |  j d |  j d t j d d ƒSWn t k
 rJ |  j ƒ  Yn Xi  S)zÁ
        We load the data from the key itself instead of fetching from
        some external data store. Opposite of _get_session_key(),
        raises BadSignature if signature fails.
        Ú
serializerZmax_ageÚsaltz/django.contrib.sessions.backends.signed_cookies)r   ÚloadsÚsession_keyr   r   ZSESSION_COOKIE_AGEÚ	ExceptionÚcreate)Úself© r   ú]/home/ubuntu/projects/ifolica/build/django/django/contrib/sessions/backends/signed_cookies.pyÚload   s    			zSessionStore.loadc             C   s   d |  _  d S)z¡
        To create a new key, we simply make sure that the modified flag is set
        so that the cookie is set on the client for the current request.
        TN)Úmodified)r   r   r   r   r      s    zSessionStore.createFc             C   s   |  j  ƒ  |  _ d |  _ d S)z½
        To save, we get the session key as a securely signed string and then
        set the modified flag so that the cookie is set on the client for the
        current request.
        TN)Ú_get_session_keyÚ_session_keyr   )r   Zmust_creater   r   r   Úsave#   s    zSessionStore.saveNc             C   s   d S)zµ
        This method makes sense when you're talking to a shared resource, but
        it doesn't matter when you're storing the information in the client's
        cookie.
        Fr   )r   r	   r   r   r   Úexists,   s    zSessionStore.existsc             C   s   d |  _  i  |  _ d |  _ d S)zÂ
        To delete, we clear the session key and the underlying data structure
        and set the modified flag so that the cookie is set on the client for
        the current request.
        Ú TN)r   Ú_session_cacher   )r   r	   r   r   r   Údelete4   s    		zSessionStore.deletec             C   s   |  j  ƒ  d S)zÈ
        Keeps the same data but with a new key.  To do this, we just have to
        call ``save()`` and it will automatically save a cookie with a new key
        at the end of the request.
        N)r   )r   r   r   r   Ú	cycle_key>   s    zSessionStore.cycle_keyc             C   s4   t  |  d i  ƒ } t j | d d d d d |  j ƒS)zþ
        Most session backends don't need to override this method, but we do,
        because instead of generating a random string, we want to actually
        generate a secure url-safe Base64-encoded string of data as our
        session key.
        r   ÚcompressTr   z/django.contrib.sessions.backends.signed_cookiesr   )Úgetattrr   Údumpsr   )r   Zsession_cacher   r   r   r   F   s
    zSessionStore._get_session_keyc             C   s   d  S)Nr   )Úclsr   r   r   Úclear_expiredT   s    zSessionStore.clear_expired)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r   r   Úclassmethodr   r   r   r   r   r      s   	
r   N)Zdjango.confr   Z%django.contrib.sessions.backends.baser   Zdjango.corer   r   r   r   r   r   Ú<module>   s   