%PDF- %PDF-
Mini Shell

Mini Shell

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

�
a�Nc@s�dZddlmZddlZddlZddlZddlZddlZddlZyddl	Z	Wne
k
r�ddlZ	nXyddlm
Z
Wn!e
k
r�ddl
m
Z
nXddlmZddlmZdefd��YZd	efd
��YZdaeaejdd�adefd��YZdefd��YZe�Zeeeeed�ZdS(s�
Creates a session object in your WSGI environment.

Use like:

..code-block:: Python

    environ['paste.session.factory']()

This will return a dictionary.  The contents of this dictionary will
be saved to disk when the request is completed.  The session will be
created when you first fetch the session dictionary, and a cookie will
be sent in that case.  There's current no way to use sessions without
cookies, and there's no way to delete a session except to clear its
data.

@@: This doesn't do any locking, and may cause problems when a single
session is accessed concurrently.  Also, it loads and saves the
session for each request, with no caching.  Also, sessions aren't
expired.
i����(tSimpleCookieN(tmd5(twsgilib(trequesttSessionMiddlewarecBseZdd�Zd�ZRS(cKs||_||_dS(N(tapplicationt
factory_kw(tselfRtglobal_confR((s>/opt/alt/python27/lib/python2.7/site-packages/paste/session.pyt__init__/s	cs�t||j���|d<g�d���fd�}|j||�}���fd�}�fd�}tj|||�S(Nspaste.session.factorycsF�js#||g�(�||�S|j�j���|||�S(N(tcreatedtappendtset_cookie_header(tstatustheaderstexc_info(tremember_headerstsession_factorytstart_response(s>/opt/alt/python27/lib/python2.7/site-packages/paste/session.pytsession_start_response8s
	

cs]�jrY�rY�\}}|j�j��td�}�|||j|df�ndS(NsLYou cannot get the session after content from the app_iter has been returned(R
RRt
ValueErrort	__class__tNone(R
Rtexc(RRR(s>/opt/alt/python27/lib/python2.7/site-packages/paste/session.pytstart@s	cs�jr�j�ndS(N(tusedtclose((R(s>/opt/alt/python27/lib/python2.7/site-packages/paste/session.pyRIs	(tSessionFactoryRRRRtadd_start_close(RtenvironRRtapp_iterRR((RRRs>/opt/alt/python27/lib/python2.7/site-packages/paste/session.pyt__call__3s
	N(t__name__t
__module__RR	R(((s>/opt/alt/python27/lib/python2.7/site-packages/paste/session.pyR-sRcBsSeZdd
dd�Zd�Zd�Zd�Zd
d�Zd�Zd	�Z	RS(t_SID_i<icKsRt|_t|_||_||_d|_|p6t|_||_	||_
dS(N(tFalseR
RRtcookie_nameRtsessiontFileSessiont
session_classtsession_class_kwt
expiration(RRR$R'tsession_expirationR(((s>/opt/alt/python27/lib/python2.7/site-packages/paste/session.pyR	Rs						cCs�t|_|jdk	r%|jj�Stj|j�}d}|j|j	�r�||j	j
|_y"|j|jdt
|j�}Wq�tk
r�q�Xn|dkr�t|_|j�|_|j|jdt|j�}n|j�||_|j�S(Ntcreate(tTrueRR%RtdataRtget_cookiesRthas_keyR$tvaluetsidR'R#R(tKeyErrorR
tmake_sidtclean_up(RtcookiesR%((s>/opt/alt/python27/lib/python2.7/site-packages/paste/session.pyRas(	

	
	cCs?|jdk	rtStj|j�}|j|j�r;tStS(N(	R%RR,RR.RR/R$R#(RR5((s>/opt/alt/python27/lib/python2.7/site-packages/paste/session.pythas_sessionxscCsEdjgtjtj��d D]}d|^q �d|j�S(Ntis%02dt-(tjointtimet	localtimet	unique_id(Rtx((s>/opt/alt/python27/lib/python2.7/site-packages/paste/session.pyR3�scCs�tj�tj�g}ttd�r=|jtj��n|dk	r_|jt|��ntt	|��}y|j
�SWnOtk
r�g}x+|j�D]}|jdt
|��q�Wdj|�SXdS(s
        Generates an opaque, identifier string that is practically
        guaranteed to be unique.  If an object is passed, then its
        id() is incorporated into the generation.  Relies on md5 and
        returns a 32 character long string.
        ttimess%02xR7N(R:trandomthasattrtosRR>RtidRtstrt	hexdigesttAttributeErrortdigesttordR9(Rt
for_objecttrtmd5_hashRDtchar((s>/opt/alt/python27/lib/python2.7/site-packages/paste/session.pyR<�s
cCs�t�}|j||j<d||jd<tjtj�|jd�}tjd|�||jd<t|�jdd�\}}||fS(Nt/tpathi<s%a, %d-%b-%Y %H:%M:%S GMTtexpiress: i(	RR1R$R:tgmtimeR)tstrftimeRCtsplit(Rtctgmt_expiration_timetnameR0((s>/opt/alt/python27/lib/python2.7/site-packages/paste/session.pyR�s	 cCs#|jdk	r|jj�ndS(N(R%RR(R((s>/opt/alt/python27/lib/python2.7/site-packages/paste/session.pyR�sNi�(
R R!RR	RR6R3R<RR(((s>/opt/alt/python27/lib/python2.7/site-packages/paste/session.pyROs
				tsecondsii<R&cBsYeZeej�ddd�Zd�Zd�Zd�Z	d�Z
d�Zd�ZRS(	i@cCs�|r't|t�r't|d�}n||_|s?t�n||_||_|s{tjj	|j
��s{t�q{nd|_||_
dS(Ni(t
isinstancet
basestringtinttchmodR2tsession_file_pathR1RARMtexiststfilenameRt_dataR)(RR1R+RZRYR)((s>/opt/alt/python27/lib/python2.7/site-packages/paste/session.pyR	�s					cCstjj|j|j�S(N(RARMR9RZR1(R((s>/opt/alt/python27/lib/python2.7/site-packages/paste/session.pyR\�scCsr|jdk	r|jStjj|j��rbt|j�d�}tj|�|_|j	�n	i|_|jS(Ntrb(
R]RRARMR[R\topentcPickletloadR(Rtf((s>/opt/alt/python27/lib/python2.7/site-packages/paste/session.pyR-�s
	cCs�|jdk	r�|j�}tjj|�}|jsO|r�tj|�q�q�t|d�}tj	|j|�|j
�|r�|jr�tj||j�q�ndS(Ntwb(R]RR\RARMR[tunlinkR_R`tdumpRRY(RR\R[Rb((s>/opt/alt/python27/lib/python2.7/site-packages/paste/session.pyR�s	
cCs�z|tjd|jd�}tjj�}xMtj|j�D]9\}}}x'|D]}|j|d|d|�qTWq>WWdta	XdS(NRUi<texp_timetnow(
tdatetimet	timedeltaR)RgRAtwalkRZt_clean_up_fileR#tcleaning_up(RRfRgtroottdirstfilesRb((s>/opt/alt/python27/lib/python2.7/site-packages/paste/session.pyt	_clean_up�s"
%c
Cs�|jd�}t|�dkr%dS|d}yptjt|dd!�t|dd!�t|dd!�t|dd!�t|dd!�t|dd	!��}Wntk
r�dSX|||kr�tjtjj|j	|��ndS(
NR8iiiiii
ii(
RQtlenRhRXRRAtremoveRMR9RZ(RRbRfRgttt	sess_time((s>/opt/alt/python27/lib/python2.7/site-packages/paste/session.pyRk�s 

cCs�tjj�}trdSts0tt|kr~ts~tay)|atjd|j�}|j	�Wq{t
a�q{Xq~ndS(Nttarget(RhRgRltlast_cleanupt
cleanup_cycleR,t	threadingtThreadRpRR#(RRgRs((s>/opt/alt/python27/lib/python2.7/site-packages/paste/session.pyR4sN(
R R!R#ttempfilet
gettempdirRR	R\R-RRpRkR4(((s>/opt/alt/python27/lib/python2.7/site-packages/paste/session.pyR&�s				
	t
_NoDefaultcBseZd�ZRS(cCsdS(Ns<dynamic default>((R((s>/opt/alt/python27/lib/python2.7/site-packages/paste/session.pyt__repr__s(R R!R}(((s>/opt/alt/python27/lib/python2.7/site-packages/paste/session.pyR|scCs�|tkr!|jdd
�}nt|�}|tkrN|jdd�}nt|�}|tkr{|jdd�}n|tkr�|jdd	�}n|tkr�|jd
d�}nt|d|d|d|d|d|�S(s
    Adds a middleware that handles sessions for your applications.
    The session is a peristent dictionary.  To get this dictionary
    in your application, use ``environ['paste.session.factory']()``
    which returns this persistent dictionary.

    Configuration:

      session_expiration:
          The time each session lives, in minutes.  This controls
          the cookie expiration.  Default 12 hours.

      expiration:
          The time each session lives on disk.  Old sessions are
          culled from disk based on this.  Default 48 hours.

      cookie_name:
          The cookie name used to track the session.  Use different
          names to avoid session clashes.

      session_file_path:
          Sessions are put in this location, default /tmp.

      chmod:
          The octal chmod you want to apply to new sessions (e.g., 660
          to make the sessions group readable/writable)

    Each of these also takes from the global configuration.  cookie_name
    and chmod take from session_cookie_name and session_chmod
    R*i<iR)i0tsession_cookie_nameR"RZs/tmpt
session_chmodR$RYi�i@N(t	NoDefaulttgetRXRR(tappRR*R)R$RZRY((s>/opt/alt/python27/lib/python2.7/site-packages/paste/session.pytmake_session_middlewares %i�(t__doc__tCookieRR:R?RARhRxRzR`tImportErrortpicklethashlibRtpasteRRtobjectRRRRvR#RlRiRwR&R|R�R�(((s>/opt/alt/python27/lib/python2.7/site-packages/paste/session.pyt<module>s<

"]h	

Zerion Mini Shell 1.0