o
    <g                     @   s,   d dl mZ d dlmZ G dd deZdS )    )SessionBase)signingc                   @   s   e Zd Zdd Zdd Zdd Zdd Zd!d
dZd!ddZd"ddZ	d"ddZ
d"ddZd"ddZdd Zdd Zdd Zedd Zedd  ZdS )#SessionStorec                 C   s:   zt j| j| j|  ddW S  ty   |   Y i S w )z
        Load the data from the key itself instead of fetching from some
        external data store. Opposite of _get_session_key(), raise BadSignature
        if signature fails.
        /django.contrib.sessions.backends.signed_cookies)
serializermax_agesalt)r   loadssession_keyr   get_session_cookie_age	Exceptioncreateself r   b/var/www/html/venv/lib/python3.10/site-packages/django/contrib/sessions/backends/signed_cookies.pyload   s   
zSessionStore.loadc                    
   |   S N)r   r   r   r   r   aload      zSessionStore.aloadc                 C   s
   d| _ dS )z
        To create a new key, set the modified flag so that the cookie is set
        on the client for the current request.
        TN)modifiedr   r   r   r   r      s   
zSessionStore.createc                    r   r   )r   r   r   r   r   acreate$   r   zSessionStore.acreateFc                 C   s   |   | _d| _dS )z
        To save, 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   must_creater   r   r   save'   s   

zSessionStore.savec                       | j |dS )N)r   r   r   r   r   r   asave0      zSessionStore.asaveNc                 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   exists3   s   zSessionStore.existsc                    r   N)r
   )r#   r"   r   r   r   aexists;   r!   zSessionStore.aexistsc                 C   s   d| _ i | _d| _dS )z
        To delete, 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   delete>   s   
zSessionStore.deletec                    r   r$   )r(   r"   r   r   r   adeleteH   r!   zSessionStore.adeletec                 C   s   |    dS )z
        Keep the same data but with a new key. Call save() and it will
        automatically save a cookie with a new key at the end of the request.
        Nr   r   r   r   r   	cycle_keyK   s   zSessionStore.cycle_keyc                    r   r   )r*   r   r   r   r   
acycle_keyR   r   zSessionStore.acycle_keyc                 C   s   t j| jdd| jdS )z
        Instead of generating a random string, generate a secure url-safe
        base64-encoded string of data as our session key.
        Tr   )compressr   r   )r   dumps_sessionr   r   r   r   r   r   U   s   zSessionStore._get_session_keyc                 C   s   d S r   r   clsr   r   r   clear_expireda   s   zSessionStore.clear_expiredc                    s   d S r   r   r/   r   r   r   aclear_expirede   s   zSessionStore.aclear_expired)Fr   )__name__
__module____qualname__r   r   r   r   r   r    r#   r%   r(   r)   r*   r+   r   classmethodr1   r2   r   r   r   r   r      s$    

	





r   N)%django.contrib.sessions.backends.baser   django.corer   r   r   r   r   r   <module>   s    