ó
    ¹Rjà-  ã                   óÒ   • S SK r S SKrS SKJrJr  S SKJr  S SKJr  S SKJ	r	  S SK
Jr  S SKJr  \R                  \R                  -   r " S S	\5      r " S
 S\5      r " S S5      rg)é    N)ÚdatetimeÚ	timedelta)Úsettings)Úsigning)Útimezone)Úget_random_string)Úimport_stringc                   ó   • \ rS rSrSrSrg)ÚCreateErroré   z{
Used internally as a consistent exception type to catch from save (see the
docstring for SessionBase.save() for details).
© N©Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__static_attributes__r   ó    ÚQD:\diplom_project\venv\Lib\site-packages\django/contrib/sessions/backends/base.pyr   r      s   † ñò
 	r   r   c                   ó   • \ rS rSrSrSrg)ÚUpdateErroré   z>
Occurs if Django tries to update a session that was deleted.
r   Nr   r   r   r   r   r      s   † ñò 	r   r   c                   ó~  • \ rS rSrSrSrSr\" 5       rS/S jr	S r
S rS	 rS
 r\S 5       rS/S jr\4S jrS rS rS rS rS rS rS rS rS rS rS rS rS rS rS r S r!S r"S r#\" \"5      r$\" \"\#5      r%S0S  jr&\" \&5      r'S! r(S" r)S# r*S$ r+S% r,S& r-S' r.S( r/S) r0S0S* jr1S/S+ jr2S, r3\4S- 5       r5S.r6g)1ÚSessionBaseé!   z%
Base class for all Session classes.
Ú
testcookieÚworkedNc                 óh   • Xl         SU l        SU l        [        [        R
                  5      U l        g )NF)Ú_session_keyÚaccessedÚmodifiedr	   r   ÚSESSION_SERIALIZERÚ
serializer©ÚselfÚsession_keys     r   Ú__init__ÚSessionBase.__init__+   s(   € Ø'ÔØˆŒØˆŒÜ'¬×(CÑ(CÓDˆ�r   c                 ó   • XR                   ;   $ ©N©Ú_session©r&   Úkeys     r   Ú__contains__ÚSessionBase.__contains__1   ó   € Ø—m‘mÑ#Ð#r   c                 ó    • U R                   U   $ r+   r,   r.   s     r   Ú__getitem__ÚSessionBase.__getitem__4   s   € Ø�}‰}˜SÑ!Ð!r   c                 ó.   • X R                   U'   SU l        g ©NT©r-   r"   ©r&   r/   Úvalues      r   Ú__setitem__ÚSessionBase.__setitem__7   s   € Ø"�‰�cÑØˆ�r   c                 ó,   • U R                   U	 SU l        g r7   r8   r.   s     r   Ú__delitem__ÚSessionBase.__delitem__;   s   € Ø�M‰M˜#ÐØˆ�r   c                 ó4   • SU R                   R                  -   $ )Nzdjango.contrib.sessions.)Ú	__class__r   ©r&   s    r   Úkey_saltÚSessionBase.key_salt?   s   € à)¨D¯N©N×,GÑ,GÑGÐGr   c                 ó8   • U R                   R                  X5      $ r+   )r-   Úget)r&   r/   Údefaults      r   rF   ÚSessionBase.getC   s   € Ø�}‰}× Ñ  Ó.Ð.r   c                 ó®   • U R                   =(       d    XR                  ;   U l         X R                  L a  SOU4nU R                  R                  " U/UQ76 $ )Nr   )r"   r-   Ú_SessionBase__not_givenÚpop)r&   r/   rG   Úargss       r   rK   ÚSessionBase.popF   sG   € ØŸ™×=¨·±Ñ)=ˆŒØ× 0Ñ 0Ò0‰r°w°jˆØ�}‰}× Ò  Ð, tÒ,Ð,r   c                 ól   • XR                   ;   a  U R                   U   $ SU l        X R                   U'   U$ r7   r8   r9   s      r   Ú
setdefaultÚSessionBase.setdefaultK   s3   € Ø—-‘-ÓØ—=‘= Ñ%Ð%à ˆDŒMØ!&�M‰M˜#ÑØˆLr   c                 ó4   • U R                   X R                  '   g r+   )ÚTEST_COOKIE_VALUEÚTEST_COOKIE_NAMErB   s    r   Úset_test_cookieÚSessionBase.set_test_cookieS   s   € Ø&*×&<Ñ&<ˆ×"Ñ"Ò#r   c                 óR   • U R                  U R                  5      U R                  :H  $ r+   )rF   rS   rR   rB   s    r   Útest_cookie_workedÚSessionBase.test_cookie_workedV   s"   € Ø�x‰x˜×-Ñ-Ó.°$×2HÑ2HÑHÐHr   c                 ó   • X R                   	 g r+   )rS   rB   s    r   Údelete_test_cookieÚSessionBase.delete_test_cookieY   s   € Ø×&Ñ&Ñ'r   c                 óX   • [         R                  " UU R                  U R                  SS9$ )zGReturn the given session dictionary serialized and encoded as a string.T)Úsaltr$   Úcompress)r   ÚdumpsrC   r$   )r&   Úsession_dicts     r   ÚencodeÚSessionBase.encode\   s'   € ä�}Š}ØØ—‘Ø—‘Øñ	
ð 	
r   c                 óò   •  [         R                  " XR                  U R                  S9$ ! [         R                   a+    [
        R                  " S5      nUR                  S5         0 $ [         a     0 $ f = f)N)r]   r$   z!django.security.SuspiciousSessionzSession data corrupted)	r   ÚloadsrC   r$   ÚBadSignatureÚloggingÚ	getLoggerÚwarningÚ	Exception)r&   Úsession_dataÚloggers      r   ÚdecodeÚSessionBase.decodee   su   € ð
	Ü—=’=Ø§=¡=¸T¿_¹_ñð øô ×#Ñ#ó 	5Ü×&Ò&Ð'JÓKˆFØ�N‰NÐ3Õ4ð
 ˆ	ô	 ó 	ð Øˆ	ð		ús   ‚(+ «;A6Á)	A6Á5A6c                 óH   • U R                   R                  U5        SU l        g r7   )r-   Úupdater"   )r&   Údict_s     r   ro   ÚSessionBase.updates   s   € Ø�‰×Ñ˜UÔ#Øˆ�r   c                 ó   • XR                   ;   $ r+   r,   r.   s     r   Úhas_keyÚSessionBase.has_keyw   r2   r   c                 ó6   • U R                   R                  5       $ r+   )r-   ÚkeysrB   s    r   rv   ÚSessionBase.keysz   s   € Ø�}‰}×!Ñ!Ó#Ð#r   c                 ó6   • U R                   R                  5       $ r+   )r-   ÚvaluesrB   s    r   ry   ÚSessionBase.values}   s   € Ø�}‰}×#Ñ#Ó%Ð%r   c                 ó6   • U R                   R                  5       $ r+   )r-   ÚitemsrB   s    r   r|   ÚSessionBase.items€   s   € Ø�}‰}×"Ñ"Ó$Ð$r   c                 ó.   • 0 U l         SU l        SU l        g r7   )Ú_session_cacher!   r"   rB   s    r   ÚclearÚSessionBase.clearƒ   s   € ð !ˆÔØˆŒØˆ�r   c                 óv   •  U R                   (       + =(       a    U R                  (       + $ ! [         a     gf = f)zBReturn True when there is no session_key and the session is empty.T)r    r   ÚAttributeErrorrB   s    r   Úis_emptyÚSessionBase.is_empty‹   s6   € ð	Ø×(Ñ(Ô(×D°×1DÑ1DÔ-DÐDøÜó 	Ùð	ús   ‚(+ «
8·8c                 óX   •  [        S[        5      nU R                  U5      (       d  U$ M*  )z)Return session key that isn't being used.é    )r   ÚVALID_KEY_CHARSÚexistsr%   s     r   Ú_get_new_session_keyÚ SessionBase._get_new_session_key’   s+   € àÜ+¨B´Ó@ˆKØ—;‘;˜{×+Ñ+Ø"Ð"ñ r   c                 ó^   • U R                   c  U R                  5       U l         U R                   $ r+   )r    rŠ   rB   s    r   Ú_get_or_create_session_keyÚ&SessionBase._get_or_create_session_key™   s+   € Ø×ÑÑ$Ø $× 9Ñ 9Ó ;ˆDÔØ× Ñ Ð r   c                 ó0   • U=(       a    [        U5      S:¬  $ )z|
Key must be truthy and at least 8 characters long. 8 characters is an
arbitrary lower bound for some minimal key security.
é   )Úlenr.   s     r   Ú_validate_session_keyÚ!SessionBase._validate_session_keyž   s   € ð
 ×$”s˜3“x 1‘}Ð$r   c                 ó   • U R                   $ r+   )Ú_SessionBase__session_keyrB   s    r   Ú_get_session_keyÚSessionBase._get_session_key¥   s   € Ø×!Ñ!Ð!r   c                 óL   • U R                  U5      (       a  Xl        gSU l        g)zF
Validate session key on assignment. Invalid values will set to None.
N)r’   r•   ©r&   r:   s     r   Ú_set_session_keyÚSessionBase._set_session_key¨   s#   € ð ×%Ñ% e×,Ñ,Ø!&Õà!%ˆDÕr   c                 óÚ   • SU l          U R                  $ ! [         aK    U R                  b  U(       a  0 U l         U R                  $ U R	                  5       U l         U R                  $ f = f)z†
Lazily load session from storage (unless "no_load" is True, when only
an empty dict is stored) and store it in the current instance.
T)r!   r   rƒ   r'   Úload)r&   Úno_loads     r   Ú_get_sessionÚSessionBase._get_session´   sk   € ð
 ˆŒð	2Ø×&Ñ&Ð&øÜó 	2Ø×ÑÑ'®7Ø&(�Õ#ð ×"Ñ"Ð"ð '+§i¡i£k�Õ#Ø×"Ñ"Ð"ð	2ús   ‰ •%A*ÁA*Á)A*c                 ó"   • [         R                  $ r+   )r   ÚSESSION_COOKIE_AGErB   s    r   Úget_session_cookie_ageÚ"SessionBase.get_session_cookie_ageÅ   s   € Ü×*Ñ*Ð*r   c                 ó¤  •  US   n US   nU(       d  U R	                  5       $ [        U[        [        45      (       d  U$ [        U[        5      (       a  [        R                  " U5      nX2-
  nUR                  S-  UR                  -   $ ! [          a    [        R                  " 5       n N¦f = f! [          a    U R                  S5      n NÁf = f)z½Get the number of seconds until the session expires.

Optionally, this function accepts `modification` and `expiry` keyword
arguments specifying the modification and expiry of the session.
ÚmodificationÚexpiryÚ_session_expiryi€Q )ÚKeyErrorr   ÚnowrF   r£   Ú
isinstancer   ÚstrÚfromisoformatÚdaysÚseconds)r&   Úkwargsr¦   r§   Údeltas        r   Úget_expiry_ageÚSessionBase.get_expiry_ageÈ   sÂ   € ð	*Ø! .Ñ1ˆLð	1Ø˜HÑ%ˆFö Ø×.Ñ.Ó0Ð0Ü˜&¤8¬S /×2Ñ2ØˆMÜ�fœc×"Ñ"Ü×+Ò+¨FÓ3ˆFØÑ%ˆØ�z‰z˜EÑ! E§M¡MÑ1Ð1øô# ó 	*Ü#Ÿ<š<›>ŠLð	*ûô ó 	1Ø—X‘XÐ/Ó0ŠFð	1ús"   ‚B ˆB1 ÂB.Â-B.Â1CÃCc                 ót  •  US   n US   n[	        U[
        5      (       a  U$ [	        U[        5      (       a  [
        R                  " U5      $ U=(       d    U R                  5       nU[        US9-   $ ! [          a    [        R                  " 5       n NŽf = f! [          a    U R                  S5      n N©f = f)z¼Get session the expiry date (as a datetime object).

Optionally, this function accepts `modification` and `expiry` keyword
arguments specifying the modification and expiry of the session.
r¦   r§   r¨   )r¯   )
r©   r   rª   rF   r«   r   r¬   r­   r£   r   )r&   r°   r¦   r§   s       r   Úget_expiry_dateÚSessionBase.get_expiry_dateã   s°   € ð	*Ø! .Ñ1ˆLð	1Ø˜HÑ%ˆFô �fœh×'Ñ'ØˆMÜ˜¤×$Ñ$Ü×)Ò)¨&Ó1Ð1Ø×8˜4×6Ñ6Ó8ˆØœi°Ñ7Ñ7Ð7øô ó 	*Ü#Ÿ<š<›>ŠLð	*ûô
 ó 	1Ø—X‘XÐ/Ó0ŠFð	1ús"   ‚A4 ˆB Á4BÂBÂB7Â6B7c                 óà   • Uc   U S	 g[        U[        5      (       a  [        R                  " 5       U-   n[        U[
        5      (       a  UR                  5       nXS'   g! [          a     gf = f)aÚ  
Set a custom expiration for the session. ``value`` can be an integer,
a Python ``datetime`` or ``timedelta`` object or ``None``.

If ``value`` is an integer, the session will expire after that many
seconds of inactivity. If set to ``0`` then the session will expire on
browser close.

If ``value`` is a ``datetime`` or ``timedelta`` object, the session
will expire at that specific future time.

If ``value`` is ``None``, the session uses the global session expiry
policy.
Nr¨   )r©   r«   r   r   rª   r   Ú	isoformatr™   s     r   Ú
set_expiryÚSessionBase.set_expiryú   sr   € ð ‰=ðØÐ*Ð+ð Ü�eœY×'Ñ'Ü—L’L“N UÑ*ˆEÜ�eœX×&Ñ&Ø—O‘OÓ%ˆEØ"'ÐÒøô ó ØØðús   …A  Á 
A-Á,A-c                 óT   • U R                  S5      =nc  [        R                  $ US:H  $ )zÚ
Return ``True`` if the session is set to expire when the browser
closes, and ``False`` if there's an expiry date. Use
``get_expiry_date()`` or ``get_expiry_age()`` to find the actual expiry
date/age, if there is one.
r¨   r   )rF   r   ÚSESSION_EXPIRE_AT_BROWSER_CLOSE)r&   r§   s     r   Úget_expire_at_browser_closeÚ'SessionBase.get_expire_at_browser_close  s/   € ð —h‘hÐ0Ó1Ð1ˆFÑ:Ü×;Ñ;Ð;Ø˜‰{Ðr   c                 óR   • U R                  5         U R                  5         SU l        g)zK
Remove the current session data from the database and regenerate the
key.
N)r€   Údeleter    rB   s    r   ÚflushÚSessionBase.flush!  s   € ð
 	�
‰
ŒØ�‰ŒØ ˆÕr   c                 ó’   • U R                   nU R                  nU R                  5         Xl        U(       a  U R	                  U5        gg)zE
Create a new session key, while retaining the current session data.
N)r-   r'   Úcreater   rÀ   )r&   Údatar/   s      r   Ú	cycle_keyÚSessionBase.cycle_key*  s;   € ð �}‰}ˆØ×ÑˆØ�‰ŒØ"ÔÞØ�K‰K˜Õð r   c                 ó   • [        S5      e)z6
Return True if the given session_key already exists.
z9subclasses of SessionBase must provide an exists() method©ÚNotImplementedErrorr%   s     r   r‰   ÚSessionBase.exists7  s   € ô "ØGó
ð 	
r   c                 ó   • [        S5      e)z¥
Create a new session instance. Guaranteed to create a new object with
a unique key and will have saved the result once (with empty data)
before the method returns.
z8subclasses of SessionBase must provide a create() methodrÉ   rB   s    r   rÄ   ÚSessionBase.create?  s   € ô "ØFó
ð 	
r   c                 ó   • [        S5      e)zÄ
Save the session data. If 'must_create' is True, create a new session
object (or raise CreateError). Otherwise, only update an existing
object and don't create one (raise UpdateError if needed).
z6subclasses of SessionBase must provide a save() methodrÉ   )r&   Úmust_creates     r   ÚsaveÚSessionBase.saveI  s   € ô "ØDó
ð 	
r   c                 ó   • [        S5      e)z`
Delete the session data under this key. If the key is None, use the
current session key value.
z8subclasses of SessionBase must provide a delete() methodrÉ   r%   s     r   rÀ   ÚSessionBase.deleteS  s   € ô
 "ØFó
ð 	
r   c                 ó   • [        S5      e)z0
Load the session data and return a dictionary.
z6subclasses of SessionBase must provide a load() methodrÉ   rB   s    r   r�   ÚSessionBase.load\  s   € ô "ØDó
ð 	
r   c                 ó   • [        S5      e)zò
Remove expired sessions from the session store.

If this operation isn't possible on a given backend, it should raise
NotImplementedError. If it isn't necessary, because the backend has
a built-in expiration mechanism, it should be a no-op.
z.This backend does not support clear_expired().rÉ   )Úclss    r   Úclear_expiredÚSessionBase.clear_expiredd  s   € ô "Ð"RÓSÐSr   )Ú__session_keyr   r    r!   r"   r$   r+   )F)7r   r   r   r   r   rS   rR   ÚobjectrJ   r(   r0   r4   r;   r>   ÚpropertyrC   rF   rK   rO   rT   rW   rZ   ra   rl   ro   rs   rv   ry   r|   r€   r„   rŠ   r�   r’   r–   rš   r'   r    rŸ   r-   r£   r²   rµ   r¹   r½   rÁ   rÆ   r‰   rÄ   rÐ   rÀ   r�   ÚclassmethodrØ   r   r   r   r   r   r   !   s4  † ñð $ÐØ Ðá“(€KôEò$ò"òòð ñHó ðHô/ð  +ô -ò
ò=òIò(ò
òòò$ò$ò&ò%òòò#ò!ò
%ò"ò&ñ Ð+Ó,€KÙÐ,Ð.>Ó?€Lô#ñ ˜Ó%€Hò+ò2ò68ò.(ò8	ò!ò	ò
ò
ô
ô
ò
ð ñTó óTr   r   )rf   Ústringr   r   Údjango.confr   Údjango.corer   Údjango.utilsr   Údjango.utils.cryptor   Údjango.utils.module_loadingr	   Úascii_lowercaseÚdigitsrˆ   ri   r   r   r   r   r   r   Ú<module>ræ      sY   ðÛ Û ß (å  Ý Ý !Ý 1Ý 5ð ×(Ñ(¨6¯=©=Ñ8€ô	�)ô 	ô	�)ô 	÷LTò LTr   