a
    Lcòfµ
  ã                   @   sD   d dl mZ d dlmZmZmZ d dlmZ dZG dd„ deƒZ	dS )é    )Úsettings)ÚCreateErrorÚSessionBaseÚUpdateError)Úcacheszdjango.contrib.sessions.cachec                       sj   e Zd ZdZeZd‡ fdd„	Zedd„ ƒZdd„ Z	d	d
„ Z
ddd„Zdd„ Zddd„Zedd„ ƒZ‡  ZS )ÚSessionStorez&
    A cache-based session store.
    Nc                    s   t tj | _tƒ  |¡ d S ©N)r   r   ZSESSION_CACHE_ALIASÚ_cacheÚsuperÚ__init__©ÚselfÚsession_key©Ú	__class__© úc/home/httpd/docs/test/DocsMgr/lib/python3.9/site-packages/django/contrib/sessions/backends/cache.pyr      s    zSessionStore.__init__c                 C   s   | j |  ¡  S r   )Úcache_key_prefixZ_get_or_create_session_key)r   r   r   r   Ú	cache_key   s    zSessionStore.cache_keyc                 C   s@   z| j  | j¡}W n ty(   d }Y n0 |d ur6|S d | _i S r   )r	   Úgetr   Ú	ExceptionÚ_session_key)r   Zsession_datar   r   r   Úload   s    
zSessionStore.loadc              	   C   sV   t dƒD ]@}|  ¡ | _z| jdd� W n ty<   Y qY n0 d| _ d S tdƒ‚d S )Ni'  T)Úmust_createzOUnable to create a new session key. It is likely that the cache is unavailable.)ÚrangeZ_get_new_session_keyr   Úsaver   ÚmodifiedÚRuntimeError)r   Úir   r   r   Úcreate#   s    

ÿzSessionStore.createFc                 C   sj   | j d u r|  ¡ S |r | jj}n | j | j¡d ur<| jj}nt‚|| j| j|d�|  	¡ ƒ}|rf|sft
‚d S )N)Zno_load)r   r   r	   Úaddr   r   Úsetr   Z_get_sessionZget_expiry_ager   )r   r   ÚfuncÚresultr   r   r   r   6   s    



ýzSessionStore.savec                 C   s   t |ƒo| j| | jv S r   )Úboolr   r	   r   r   r   r   ÚexistsG   s    ÿzSessionStore.existsc                 C   s2   |d u r| j d u rd S | j }| j | j| ¡ d S r   )r   r	   Údeleter   r   r   r   r   r&   L   s
    
zSessionStore.deletec                 C   s   d S r   r   )Úclsr   r   r   Úclear_expiredS   s    zSessionStore.clear_expired)N)F)N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú
KEY_PREFIXr   r   Úpropertyr   r   r   r   r%   r&   Úclassmethodr(   Ú__classcell__r   r   r   r   r      s   


r   N)
Zdjango.confr   Z%django.contrib.sessions.backends.baser   r   r   Zdjango.core.cacher   r-   r   r   r   r   r   Ú<module>   s   