%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /opt/alt/python27/lib/python2.7/site-packages/beaker/
Upload File :
Create Path :
Current File : //opt/alt/python27/lib/python2.7/site-packages/beaker/session.pyo

�
��Wc@sJddlZddlZddlZddlZddlmZmZddlmZm	Z
mZddlm
Z
ddlmZddlmZddlmZmZddlmZmZd	d
gZeed�o�ejp�d�Zd	ejfd
��YZd
efd��YZdefd��YZde fd��YZ!dS(i����N(tdatetimet	timedelta(thmact	hmac_sha1tsha1(tpickle(tcrypto(tclsmap(tBeakerExceptiontInvalidCryptoBackendError(t	b64encodet	b64decodetSignedCookietSessiontgetpidcCsdS(Nt((((s?/opt/alt/python27/lib/python2.7/site-packages/beaker/session.pyt<lambda>scBs,eZdZdd�Zd�Zd�ZRS(s7Extends python cookie to give digital signature supportcCs ||_tjj||�dS(N(tsecrettCookiet
BaseCookiet__init__(tselfRtinput((s?/opt/alt/python27/lib/python2.7/site-packages/beaker/session.pyRs	cCs�|jd�}tj|j|dt�j�}d}|d }t|�t|�krcd|fSx-t||�D]\}}|||k7}qsW|r�d|fS|d|fSdS(Nt"i(i(	tstriptHMACtnewRtSHA1t	hexdigesttlentNonetzip(Rtvaltsigtinvalid_bitst	input_sigtatb((s?/opt/alt/python27/lib/python2.7/site-packages/beaker/session.pytvalue_decodes"


cCs8tj|j|t�j�}t|�d||ffS(Ns%s%s(RRRRRtstr(RR R!((s?/opt/alt/python27/lib/python2.7/site-packages/beaker/session.pytvalue_encode,sN(t__name__t
__module__t__doc__RRR&R((((s?/opt/alt/python27/lib/python2.7/site-packages/beaker/session.pyRs	c
Bs�eZdZdeeddddeddedd�Zd�Zd�Ze	e�Zd�Z
d�Ze	ee
�Zd�Z
d�Ze	ee
�Zd	�Zd
�Zd�Zd�Zed
�Zd�Zd�Zd�ZRS(s�Session object that uses container package for storage.
    
    ``key``
        The name the cookie should be set to.
    ``timeout``
        How long session data is considered valid. This is used 
        regardless of the cookie being present or not to determine
        whether session data is still valid.
    ``cookie_domain``
        Domain to use for the cookie.
    ``secure``
        Whether or not the cookie should only be sent over SSL.
    sbeaker.session.idcKs�|s$|rd|_q-d|_n	||_|
p=t|j|_||_||_||_||_||_||_|	|_	|
|_
d|_t|_
||_||_||_i|_|jrw|jdd�}|r*yt|d|�|_Wq?tjk
r&t|dd�|_q?Xntjd|�|_|jrw|j|jkrw|j|jj|_qwn|jdk|_|jr�|j�tj�|d<|d<n.y|j�Wn|r�|j�q��nXdS(	Ntfiletmemoryt/tcookieRRt_accessed_timet_creation_time(ttypeRtnamespace_classtnamespace_argstrequesttdata_dirtkeyttimeouttuse_cookiestcookie_expirest_domaint_pathtFalsetwas_invalidatedRtsecuretidt
accessed_dicttgetRR/RtCookieErrorRtSimpleCookietvaluetis_newt
_create_idttimetloadt
invalidate(RR5R@tinvalidate_corruptR9R2R6R7R8R:t
cookie_domainRR?R3R4tcookieheader((s?/opt/alt/python27/lib/python2.7/site-packages/beaker/session.pyR?sP																	

cCs�ttdtj�ti�tj�t�f�j��jdd�jdd�jd�|_t	|_
d|_|j
r�|j|j|j<|jr�|j|j|jd<n|jr�t	|j|jd<n|j|j|jd	<|jt	k	r�|jtkrtjd
�}n_t|jt�rAtj�|j}n7t|jt�r_|j}ntdt|j���|jd�|j|jd
<n|j|jjdd�|jd<t|jd<ndS(Ns%f%s%f%st+t-R.t_t=tdomainR?tpathi���s'Invalid argument for cookie_expires: %ss%a, %d-%b-%Y %H:%M:%S GMTtexpirestheaderRt
cookie_outt
set_cookie(R
RRHR@trandomRtdigesttreplacetrstriptTrueRFRt
last_accessedR9R/R7R;R?R<R:R=Rt
fromtimestampt
isinstanceRttodayt
ValueErrortreprtstrftimetoutputR5(RRT((s?/opt/alt/python27/lib/python2.7/site-packages/beaker/session.pyRG{s2!$					 #cCs|dS(NR1((R((s?/opt/alt/python27/lib/python2.7/site-packages/beaker/session.pytcreated�scCsR||d<||j|jd<|j|jjdd�|jd<t|jd<dS(NR;RRRURRVRW(R/R7RdR5R\(RRR((s?/opt/alt/python27/lib/python2.7/site-packages/beaker/session.pyt_set_domain�s
#cCs|jS(N(R;(R((s?/opt/alt/python27/lib/python2.7/site-packages/beaker/session.pyt_get_domain�scCsR||d<||j|jd<|j|jjdd�|jd<t|jd<dS(NR<RSRURRVRW(R/R7RdR5R\(RRS((s?/opt/alt/python27/lib/python2.7/site-packages/beaker/session.pyt	_set_path�s
#cCs|jS(N(R<(R((s?/opt/alt/python27/lib/python2.7/site-packages/beaker/session.pyt	_get_path�scCs�t|jd<|j|j|j<|jrC|j|j|jd<n|jrct|j|jd<nd|j|jd<tj�j	dd�}|j
d�|j|jd	<|j|jjd
d�|jd<t|jd<dS(
NRWRRR?R.RStyeari�s%a, %d-%b-%Y %H:%M:%S GMTRTRURRV(R\R5R@R/R7R;R?RR`RZRcRd(RRT((s?/opt/alt/python27/lib/python2.7/site-packages/beaker/session.pyt_delete_cookie�s
		#cCs$|jr|j�n|j�dS(sXDeletes the session from the persistent storage, and sends
        an expired cookie outN(R9Rktclear(R((s?/opt/alt/python27/lib/python2.7/site-packages/beaker/session.pytdelete�s	
cCs+|j�t|_|j�|j�dS(sWInvalidates this session, creates a new session id, returns
        to the is_new stateN(RlR\R>RGRI(R((s?/opt/alt/python27/lib/python2.7/site-packages/beaker/session.pyRJ�s
	
cCs�|j|jd|jdt|j�|_tj�}t|jd<|jj	�t}z|j
�y=|jd}|dkr�i|d6|d6}t|_nWn4t
tfk
r�i|d6|d6}t|_nX|jdk	r||d|jkrt}nT|jsd|kr'd|_n
|d|_||d<|j|�|j�|_Wd|jj�X|r|j�ndS(s8Loads the data from this session from persistent storageR6tdigest_filenamesRWtsessionR1R0N(R3R@R6R=R4t	namespaceRHR\R5tacquire_read_lockRlRRFtKeyErrort	TypeErrorR8R]tupdatetcopyRAtrelease_read_lockRJ(Rtnowt	timed_outtsession_data((s?/opt/alt/python27/lib/python2.7/site-packages/beaker/session.pyRI�sB






	


cCs�|r|jrdSt|d�sO|j|jd|jdt|j�|_n|jj	�zd|r}t
|jj��}nt
|j��}|r�d|jkr�|jd=n
||jd<Wd|jj
�X|jr�t|jd<ndS(s�Saves the data for this session to persistent storage
        
        If accessed_only is True, then only the original data loaded
        at the beginning of the request will be saved, with the updated
        last accessed time.
        
        RpR6RnRoNRW(RFRthasattrR3R@R6R=R4Rptacquire_write_locktdictRAtitemstrelease_write_lockR\R5(Rt
accessed_onlytdata((s?/opt/alt/python27/lib/python2.7/site-packages/beaker/session.pytsaves&
		

	cCs|j�|j|j�dS(sURevert the session to its original state from its first
        access in the requestN(RlRtRA(R((s?/opt/alt/python27/lib/python2.7/site-packages/beaker/session.pytrevert&s
cCs|jj�dS(sHLocks this session against other processes/threads.  This is
        automatic when load/save is called.
        
        ***use with caution*** and always with a corresponding 'unlock'
        inside a "finally:" block, as a stray lock typically cannot be
        unlocked without shutting down the whole application.

        N(RpR{(R((s?/opt/alt/python27/lib/python2.7/site-packages/beaker/session.pytlock/s	cCs|jj�dS(s$Unlocks this session against other processes/threads.  This
        is automatic when load/save is called.

        ***use with caution*** and always within a "finally:" block, as
        a stray lock typically cannot be unlocked without shutting down
        the whole application.

        N(RpR~(R((s?/opt/alt/python27/lib/python2.7/site-packages/beaker/session.pytunlock:s	N(R)R*R+RR=R\RRGRetpropertyRfRgRRRhRiRSRkRmRJRIR�R�R�R�(((s?/opt/alt/python27/lib/python2.7/site-packages/beaker/session.pyR
1s.
			8										2%			t
CookieSessioncBs�eZdZddeddded�Zd�Zee�Zd�Z	ee	�Z	d�Z
d�Zeee
�Zd�Z
d�Zeee
�Zd	�Zd
�Zd�Zed�Zd
�Zd�Zd�Zd�ZRS(s�Pure cookie-based session
    
    Options recognized when using cookie-based sessions are slightly
    more restricted than general sessions.
    
    ``key``
        The name the cookie should be set to.
    ``timeout``
        How long session data is considered valid. This is used 
        regardless of the cookie being present or not to determine
        whether session data is still valid.
    ``encrypt_key``
        The key to use for the session encryption, if not provided the
        session will not be encrypted.
    ``validate_key``
        The key used to sign the encrypted session
    ``cookie_domain``
        Domain to use for the cookie.
    ``secure``
        Whether or not the cookie should only be sent over SSL.
    
    sbeaker.session.idc	Ks�tjr|rtd��n||_||_||_||_||_||_t	|jd<||_
||_d|_y|d}
Wnt
k
r�d}
nX|dkr�td��nyt|d|
�|_Wn)tjk
rt|dd�|_nX|j�|d<t|_|j|jkr�|j|jjdk	r�t	|_y|j|j��WnnX|jdk	r�tj�|d	|jkr�|j�n|j�|_|j�ndS(
NsJNo AES library is installed, can't generate encrypted cookie-only Session.RWR.R/Rs2No validate_key specified for Cookie only Session.Rt_idR0(Rthas_aesR	R5R7R8R:tencrypt_keytvalidate_keyR=R?R;R<RrRRRR/RRCt_make_idR\RFRERtt
_decrypt_dataRHRlRuRAt_create_cookie(RR5R7R8R:RLR�R�R?tkwargsRM((s?/opt/alt/python27/lib/python2.7/site-packages/beaker/session.pyR\sF						
			

	+	
cCs|dS(NR1((R((s?/opt/alt/python27/lib/python2.7/site-packages/beaker/session.pyRe�scCs|dS(NR�((R((s?/opt/alt/python27/lib/python2.7/site-packages/beaker/session.pyR@�scCs||d<||_dS(NR;(R;(RRR((s?/opt/alt/python27/lib/python2.7/site-packages/beaker/session.pyRf�s
cCs|jS(N(R;(R((s?/opt/alt/python27/lib/python2.7/site-packages/beaker/session.pyRg�scCs||d<||_dS(NR<(R<(RRS((s?/opt/alt/python27/lib/python2.7/site-packages/beaker/session.pyRh�s
cCs|jS(N(R<(R((s?/opt/alt/python27/lib/python2.7/site-packages/beaker/session.pyRi�scCs�|jrsttjd��d }tj|j|j|d�}tj|j	�d�}|ttj
||��Stj|j	�d�}t|�SdS(s0Serialize, encipher, and base64 the session dicti(iiiN(R�R
tosturandomRtgenerateCryptoKeysR�RtdumpsRut
aesEncrypt(RtnonceR�R�((s?/opt/alt/python27/lib/python2.7/site-packages/beaker/session.pyt
_encrypt_data�s	cCs�|jr{|j|jjd }tj|j|j|d�}t|j|jjd�}tj||�}t	j
|�St|j|jj�}t	j
|�SdS(sHBas64, decipher, then un-serialize the data for the session
        dictiiN(R�R/R7RERR�R�Rt
aesDecryptRtloads(RR�R�tpayloadR�((s?/opt/alt/python27/lib/python2.7/site-packages/beaker/session.pyR��s	
cCs\ttdtj�ti�tj�t�f�j��jdd�jdd�jd�S(Ns%f%s%f%sRNROR.RPRQ(	R
RRHR@RXRRYRZR[(R((s?/opt/alt/python27/lib/python2.7/site-packages/beaker/session.pyR��s:cCsD|r|jrdS|r6|j�|j|j�n|j�dS(s5Saves the data for this session to persistent storageN(RFRlRtRAR�(RR((s?/opt/alt/python27/lib/python2.7/site-packages/beaker/session.pyR��s
cCs|jdd�dS(s7Delete the 'expires' attribute on this Session, if any.t_expiresN(tpopR(R((s?/opt/alt/python27/lib/python2.7/site-packages/beaker/session.pytexpire�scCs*d|krtj�|d<nd|kr>|j�|d<ntj�|d<|jtk	r�|jtkr~tjd�}n_t|jt�r�tj	�|j}n7t|jt�r�|j}nt
dt|j���||d<nd|kr|d}nd}|j
�}t|�dkr6td��n||j|j<d	|krm|d	|j|jd
<n#|jr�|j|j|jd
<n|jr�t|j|jd<n|jdd
�|j|jd<|r�|jd�|j|jd<n|j|jjdd�|jd<t|jd<dS(NR1R�R0i���s'Invalid argument for cookie_expires: %sR�i�s!Cookie value is too long to storeR;RRR?R<R.RSs%a, %d-%b-%Y %H:%M:%S GMTRTRURRVRW(RHR�R:R\R=RR^R_RR`RaRbRR�RRR/R7R;R?RBRcRdR5(RRTR ((s?/opt/alt/python27/lib/python2.7/site-packages/beaker/session.pyR��sB

		  #cCs|j�|j�dS(s(Delete the cookie, and clear the sessionN(RkRl(R((s?/opt/alt/python27/lib/python2.7/site-packages/beaker/session.pyRm�s
cCs|j�|j�|d<dS(s*Clear the contents and start a new sessionR�N(RmR�(R((s?/opt/alt/python27/lib/python2.7/site-packages/beaker/session.pyRJs
N(R)R*R+RR\R=RReR�R@RfRgRRRhRiRSR�R�R�R�R�R�RmRJ(((s?/opt/alt/python27/lib/python2.7/site-packages/beaker/session.pyR�Es,	/												+	t
SessionObjectcBs�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�ZRS(s3Session proxy/lazy creator
    
    This object proxies access to the actual session object, so that in
    the case that the session hasn't been used before, it will be
    setup. This avoid creating and loading the session from persistent
    storage unless its actually used during the request.
    
    cKs8||jd<||jd<d|jd<g|jd<dS(Nt_paramst_environt_sesst_headers(t__dict__R(Rtenvirontparams((s?/opt/alt/python27/lib/python2.7/site-packages/beaker/session.pyRs


cCs�|jdd
kr�|jd}|jd}id
d6|jd<}|jd�|d<|jd�dkr�t||�|jd<q�t|d	t|�|jd<n|jdS(s'Lazy initial creation of session objectR�R�R�RVR�tHTTP_COOKIER/R2R9N(R�RRBR�R
R\(RR�R�treq((s?/opt/alt/python27/lib/python2.7/site-packages/beaker/session.pyt_sessions

cCst|j�|�S(N(tgetattrR�(Rtattr((s?/opt/alt/python27/lib/python2.7/site-packages/beaker/session.pyt__getattr__(scCst|j�||�dS(N(tsetattrR�(RR�RE((s?/opt/alt/python27/lib/python2.7/site-packages/beaker/session.pyt__setattr__+scCs|j�j|�dS(N(R�t__delattr__(Rtname((s?/opt/alt/python27/lib/python2.7/site-packages/beaker/session.pyR�.scCs|j�|S(N(R�(RR7((s?/opt/alt/python27/lib/python2.7/site-packages/beaker/session.pyt__getitem__1scCs||j�|<dS(N(R�(RR7RE((s?/opt/alt/python27/lib/python2.7/site-packages/beaker/session.pyt__setitem__4scCs|j�j|�dS(N(R�t__delitem__(RR7((s?/opt/alt/python27/lib/python2.7/site-packages/beaker/session.pyR�7scCs|j�j�S(N(R�t__repr__(R((s?/opt/alt/python27/lib/python2.7/site-packages/beaker/session.pyR�:scCst|j�j��S(s!Only works for proxying to a dict(titerR�tkeys(R((s?/opt/alt/python27/lib/python2.7/site-packages/beaker/session.pyt__iter__=scCs|j�j|�S(N(R�thas_key(RR7((s?/opt/alt/python27/lib/python2.7/site-packages/beaker/session.pyt__contains__AscCs9|jd}tidtd||�}|jr5dS|S(s"Loads a session given a session IDR�R9R@N(R�R
R=RFR(RR@R�Ro((s?/opt/alt/python27/lib/python2.7/site-packages/beaker/session.pyt	get_by_idDs

	cCst|jd<dS(Nt_dirty(R\R�(R((s?/opt/alt/python27/lib/python2.7/site-packages/beaker/session.pyR�LscCs!t|jd<|j�j�dS(NR�(R\R�R�Rm(R((s?/opt/alt/python27/lib/python2.7/site-packages/beaker/session.pyRmOs
cCsh|jdjd�r)|j�j�n;|jjd�rN|j�j�n|j�jdt�dS(sCPersist the session to the storage
        
        If its set to autosave, then the entire session will be saved
        regardless of if save() has been called. Otherwise, just the
        accessed time will be updated if save() was not called, or
        the session will be saved if save() was called.
        
        R�tautoR�RN(R�RBR�R�R\(R((s?/opt/alt/python27/lib/python2.7/site-packages/beaker/session.pytpersistSs
	cCs|jjdt�S(NR�(R�RBR=(R((s?/opt/alt/python27/lib/python2.7/site-packages/beaker/session.pytdirtydscCs|jddk	S(s4Returns whether or not the session has been accessedR�N(R�R(R((s?/opt/alt/python27/lib/python2.7/site-packages/beaker/session.pytaccessedgs(R)R*R+RR�R�R�R�R�R�R�R�R�R�R�R�RmR�R�R�(((s?/opt/alt/python27/lib/python2.7/site-packages/beaker/session.pyR�s$																("RR�RXRHRRt
beaker.cryptoRRRRRtbeaker.utilRtbeakerRtbeaker.cacheRtbeaker.exceptionsRR	tbase64R
Rt__all__RzRRRR|R
R�tobjectR�(((s?/opt/alt/python27/lib/python2.7/site-packages/beaker/session.pyt<module>s"!��

Zerion Mini Shell 1.0