
    (ph                     r    S SK r S SKJrJrJr  S SKJr  S SKJrJ	r	J
r
Jr  S SKJr  S SKJr   " S S\5      rg)	    N)CreateErrorSessionBaseUpdateError)SuspiciousOperation)DatabaseErrorIntegrityErrorroutertransaction)timezone)cached_propertyc                      ^  \ rS rSrSrSU 4S jjr\S 5       r\S 5       r	S r
S rS rS	 rS
 rSS jrSS jr\S 5       rSrU =r$ )SessionStore
   z#
Implement database session store.
c                 $   > [         TU ]  U5        g N)super__init__)selfsession_key	__class__s     V/var/www/html/venv/lib/python3.13/site-packages/django/contrib/sessions/backends/db.pyr   SessionStore.__init__   s    %    c                     SSK Jn  U$ )Nr   )Session)django.contrib.sessions.modelsr   )clsr   s     r   get_model_classSessionStore.get_model_class   s     	;r   c                 "    U R                  5       $ r   )r   r   s    r   modelSessionStore.model   s    ##%%r   c                     U R                   R                  R                  U R                  [        R
                  " 5       S9$ ! U R                   R                  [        4 am  n[        U[        5      (       aG  [        R                  " SUR                  R                  -  5      nUR                  [        U5      5        S U l         S nAg S nAff = f)N)r   expire_date__gtzdjango.security.%s)r"   objectsgetr   r   nowDoesNotExistr   
isinstancelogging	getLoggerr   __name__warningstr_session_key)r   eloggers      r   _get_session_from_db!SessionStore._get_session_from_db   s    	%::%%)) ,,hlln *   

'')<= 	%!011 **+?!++BVBV+VWs1v& $D		%s   A A  C#A#CCc                 j    U R                  5       nU(       a  U R                  UR                  5      $ 0 $ r   )r3   decodesession_data)r   ss     r   loadSessionStore.load)   s*    %%'./t{{1>>*7R7r   c                 d    U R                   R                  R                  US9R                  5       $ N)r   )r"   r&   filterexistsr   r   s     r   r>   SessionStore.exists-   s)    zz!!(([(AHHJJr   c                      U R                  5       U l         U R                  SS9  SU l        g ! [         a     M;  f = f)NT)must_create)_get_new_session_keyr0   saver   modifiedr!   s    r   createSessionStore.create0   sK     $ 9 9 ;D 		d	+ !DM	  s   / 
==c                 z    U R                  U R                  5       U R                  U5      U R                  5       S9$ )z
Return a new instance of the session model object, which represents the
current session state. Intended to be used for saving the session data
to the database.
)r   r7   expire_date)r"   _get_or_create_session_keyencodeget_expiry_date)r   datas     r   create_model_instance"SessionStore.create_model_instance=   s>     zz779T*,,.  
 	
r   c                    U R                   c  U R                  5       $ U R                  US9nU R                  U5      n[        R
                  " U R                  US9n [        R                  " US9   UR                  X(       + US9  SSS5        g! , (       d  f       g= f! [         a    U(       a  [        ee [         a    U(       d  [        ee f = f)z
Save the current session data to the database. If 'must_create' is
True, raise a database error if the saving operation doesn't create a
new entry (as opposed to possibly updating an existing entry).
N)no_load)instance)using)force_insertforce_updaterS   )r   rF   _get_sessionrN   r	   db_for_writer"   r
   atomicrD   r   r   r   r   )r   rB   rM   objrS   s        r   rD   SessionStore.saveI   s     #;;=    5((.##DJJ=	##%0!,?RW   100  	!! 	!!	s*   B" 2BB" 
BB" B" "0Cc                     Uc  U R                   c  g U R                   n U R                  R                  R                  US9R	                  5         g ! U R                  R
                   a     g f = fr<   )r   r"   r&   r'   deleter)   r?   s     r   r\   SessionStore.deleteb   sg    '**K	JJ""{";BBDzz&& 		s   1A A.-A.c                     U R                  5       R                  R                  [        R                  " 5       S9R                  5         g )N)expire_date__lt)r   r&   r=   r   r(   r\   )r   s    r   clear_expiredSessionStore.clear_expiredl   s1    %%,,X\\^,LSSUr   )r0   rE   r   )F)r-   
__module____qualname____firstlineno____doc__r   classmethodr   r   r"   r3   r9   r>   rF   rN   rD   r\   r`   __static_attributes____classcell__)r   s   @r   r   r   
   so    &   & &	%8K

2 V Vr   r   )r+   %django.contrib.sessions.backends.baser   r   r   django.core.exceptionsr   	django.dbr   r   r	   r
   django.utilsr   django.utils.functionalr   r    r   r   <module>ro      s-     W W 6 H H ! 3dV; dVr   