%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/wsgilib.pyo

�
b�Nc@s�dZddlmZmZmZddlmZmZmZddlm	Z	m
Z
mZmZddlm
Z
mZmZddlmZddlZddlmZddlZdd	lmZddlZd
ddd
ddddddddddddddddgZd
efd��YZdefd��YZdefd ��YZdefd!��YZdd"�Z d#efd$��YZ!de"d%�Z#d&efd'��YZ$d(e%d)�Z&d*efd+��YZ'd,�Z(de(_)d-�Z*d.�Z+d/�Z,ddd0�Z-d1e	fd2��YZ.d3�Z/xSeD]KZ0e1�e0Z2e3e2d4�r8e2j4d5e5kr8e/e2�e1�e0<q8q8We5d6kr�ddl6Z6e6j7�ndS(7s&
A module of many disparate routines.
i����(tget_cookiestparse_querystringtparse_formvars(t
construct_urltpath_info_splitt
path_info_pop(t
HeaderDictt
has_headertheader_valuet
remove_header(terror_body_responseterror_responseterror_response_app(tprint_exceptionN(tStringIO(turlsplitt	add_closetadd_start_closetcapture_outputtcatch_errorstcatch_errors_apptchained_app_itersRtdump_environtencode_unicode_app_iterR
RRRRtinteractivetintercept_outputRRtraw_interactivet	send_filecBs;eZdZd�Zd�Zd�Zd�Zd�ZRS(sP
    An an iterable that iterates over app_iter, then calls
    close_func.
    cCs.||_t|�|_||_t|_dS(N(tapp_iterabletitertapp_itert
close_functFalset_closed(tselfRR((s>/opt/alt/python27/lib/python2.7/site-packages/paste/wsgilib.pyt__init__#s		cCs|S(N((R"((s>/opt/alt/python27/lib/python2.7/site-packages/paste/wsgilib.pyt__iter__)scCs
|jj�S(N(Rtnext(R"((s>/opt/alt/python27/lib/python2.7/site-packages/paste/wsgilib.pyR%,scCs9t|_t|jd�r+|jj�n|j�dS(Ntclose(tTrueR!thasattrRR&R(R"((s>/opt/alt/python27/lib/python2.7/site-packages/paste/wsgilib.pyR&/s	cCs$|js tjd|jIJndS(NsgError: app_iter.close() was not called when finishing WSGI request. finalization function %s not called(R!tsyststderrR(R"((s>/opt/alt/python27/lib/python2.7/site-packages/paste/wsgilib.pyt__del__5s	(t__name__t
__module__t__doc__R#R$R%R&R+(((s>/opt/alt/python27/lib/python2.7/site-packages/paste/wsgilib.pyRs				cBs>eZdZdd�Zd�Zd�Zd�Zd�ZRS(s�
    An an iterable that iterates over app_iter, calls start_func
    before the first item is returned, then calls close_func at the
    end.
    cCs@||_t|�|_t|_||_||_t|_dS(N(	RRRR'tfirstt
start_funcRR R!(R"RR0R((s>/opt/alt/python27/lib/python2.7/site-packages/paste/wsgilib.pyR#Ds				cCs|S(N((R"((s>/opt/alt/python27/lib/python2.7/site-packages/paste/wsgilib.pyR$LscCs,|jr|j�t|_n|jj�S(N(R/R0R RR%(R"((s>/opt/alt/python27/lib/python2.7/site-packages/paste/wsgilib.pyR%Os	
cCsKt|_t|jd�r+|jj�n|jdk	rG|j�ndS(NR&(R'R!R(RR&RtNone(R"((s>/opt/alt/python27/lib/python2.7/site-packages/paste/wsgilib.pyR&Us
	cCs$|js tjd|jIJndS(NsgError: app_iter.close() was not called when finishing WSGI request. finalization function %s not called(R!R)R*R(R"((s>/opt/alt/python27/lib/python2.7/site-packages/paste/wsgilib.pyR+\s	N(	R,R-R.R1R#R$R%R&R+(((s>/opt/alt/python27/lib/python2.7/site-packages/paste/wsgilib.pyR=s			cBs;eZdZd�Zd�Zd�Zd�Zd�ZRS(sZ
    Chains several app_iters together, also delegating .close() to each
    of them.
    cGs8||_g|D]}t|�^q|_t|_dS(N(t	app_itersRtchainedR R!(R"R3titem((s>/opt/alt/python27/lib/python2.7/site-packages/paste/wsgilib.pyR#ks	"cCs|S(N((R"((s>/opt/alt/python27/lib/python2.7/site-packages/paste/wsgilib.pyR$pscCsjt|j�dkr&|jdj�Sy|jdj�SWn(tk
re|jjd�|j�SXdS(Nii(tlenR3R%t
StopIterationtpop(R"((s>/opt/alt/python27/lib/python2.7/site-packages/paste/wsgilib.pyR%ss
cCs~t|_d}xG|jD]<}y t|d�r>|j�nWqtj�}qXqW|rz|d|d|d�ndS(NR&iii(R'R!R1R2R(R&R)texc_info(R"tgot_excR((s>/opt/alt/python27/lib/python2.7/site-packages/paste/wsgilib.pyR&}s	cCs$|js tjd|jIJndS(NsgError: app_iter.close() was not called when finishing WSGI request. finalization function %s not called(R!R)R*R(R"((s>/opt/alt/python27/lib/python2.7/site-packages/paste/wsgilib.pyR+�s	(R,R-R.R#R$R%R&R+(((s>/opt/alt/python27/lib/python2.7/site-packages/paste/wsgilib.pyRds			
	cBs>eZdZej�dd�Zd�Zd�Zd�ZRS(s@
    Encodes an app_iterable's unicode responses as strings
    tstrictcCs.||_t|�|_||_||_dS(N(RRRtencodingterrors(R"RR;R<((s>/opt/alt/python27/lib/python2.7/site-packages/paste/wsgilib.pyR#�s		cCs|S(N((R"((s>/opt/alt/python27/lib/python2.7/site-packages/paste/wsgilib.pyR$�scCs=|jj�}t|t�r9|j|j|j�}n|S(N(RR%t
isinstancetunicodetencodeR;R<(R"tcontent((s>/opt/alt/python27/lib/python2.7/site-packages/paste/wsgilib.pyR%�scCs&t|jd�r"|jj�ndS(NR&(R(RR&(R"((s>/opt/alt/python27/lib/python2.7/site-packages/paste/wsgilib.pyR&�s(	R,R-R.R)tgetdefaultencodingR#R$R%R&(((s>/opt/alt/python27/lib/python2.7/site-packages/paste/wsgilib.pyR�s			cCspy|||�}Wn|tj���nXt|�ttfkr\|rX|�n|St|||�SdS(s&
    Runs the application, and returns the application iterator (which should be
    passed upstream).  If an error occurs then error_callback will be called with
    exc_info as its sole argument.  If no errors occur and ok_callback is given,
    then it will be called with no arguments.
    N(R)R8ttypetlistttuplet_wrap_app_iter(tapplicationtenvirontstart_responseterror_callbacktok_callbackR((s>/opt/alt/python27/lib/python2.7/site-packages/paste/wsgilib.pyR�s
REcBs#eZd�Zd�Zd�ZRS(cCsR||_t|�|_||_||_t|jd�rN|jj|_ndS(NR&(RRRRIRJR(R&(R"RRIRJ((s>/opt/alt/python27/lib/python2.7/site-packages/paste/wsgilib.pyR#�s			cCs|S(N((R"((s>/opt/alt/python27/lib/python2.7/site-packages/paste/wsgilib.pyR$�scCs^y|jj�SWnFtk
r=|jr7|j�n�n|jtj���nXdS(N(RR%R6RJRIR)R8(R"((s>/opt/alt/python27/lib/python2.7/site-packages/paste/wsgilib.pyR%�s
	
(R,R-R#R$R%(((s>/opt/alt/python27/lib/python2.7/site-packages/paste/wsgilib.pyRE�s		cCs�y|||�}Wn$|k
r9|||tj��SXt|�ttfkrl|dk	rh|�n|St|||||d|�SdS(s
    Like ``catch_errors``, except error_callback_app should be a
    callable that will receive *three* arguments -- ``environ``,
    ``start_response``, and ``exc_info``.  It should call
    ``start_response`` (*with* the exc_info argument!) and return an
    iterator.
    tcatchN(R)R8RBRCRDR1t_wrap_app_iter_app(RFRGRHterror_callback_appRJRKR((s>/opt/alt/python27/lib/python2.7/site-packages/paste/wsgilib.pyR�s	

	RLcBs&eZed�Zd�Zd�ZRS(cCsm||_||_||_t|�|_||_||_||_t|jd�ri|jj	|_	ndS(NR&(
RGRHRRRRMRJRKR(R&(R"RGRHRRMRJRK((s>/opt/alt/python27/lib/python2.7/site-packages/paste/wsgilib.pyR#�s						cCs|S(N((R"((s>/opt/alt/python27/lib/python2.7/site-packages/paste/wsgilib.pyR$�scCs�y|jj�SWn�tk
r=|jr7|j�n�n�|jk
r�t|jd�r}y|jj�Wq}q}Xn|j|j	|j
tj��}t
|�}t|d�r�|j|_n|j|_|j�SXdS(NR&(RR%R6RJRKR(RR&RMRGRHR)R8R(R"tnew_app_iterableR((s>/opt/alt/python27/lib/python2.7/site-packages/paste/wsgilib.pyR%�s&
	
(R,R-t	ExceptionR#R$R%(((s>/opt/alt/python27/lib/python2.7/site-packages/paste/wsgilib.pyRL�s	tcs�|rt�}n	t�}i
dd6dd6dd6dd6dd	6d
d6d#d6dd6td�d6|d6td6td6td6}|r�tt|��\}}}}}	tj|�}t|�t|�}}||d<|r�||d<q�nx6|j�D](\}
}|
jdd�}
|||
<q�Wd|krSd|krS|d|d<n|d}t	|t�r�t|�|d<t
|�|d<ni�g�g�g�d����fd�}
|||
�}z�yfx_|D]W}t	|t�std|��n�j
t��s(td��n�j
|�q�WWn<tk
rx}|jd
d|f|jd|_�nXWdt|d �r�|j�nX�d!�d"dj��|j�fS($s5
    Runs the application in a fake environment.
    tGETtREQUEST_METHODRPtSCRIPT_NAMEt	PATH_INFOt	localhosttSERVER_NAMEt80tSERVER_PORTsHTTP/1.0tSERVER_PROTOCOLiiswsgi.versionthttpswsgi.url_schemes
wsgi.inputswsgi.errorsswsgi.multithreadswsgi.multiprocesss
wsgi.run_oncetQUERY_STRINGt__t.t	HTTP_HOSTtCONTENT_LENGTHcsu|r8z%�r*|d|d|d�nWdd}Xn�rMtd��n�jt�|�d<|�d<�jS(Niiis$Headers already set and no exc_info!tstatustheaders(R1tAssertionErrortappendR'(R`RaR8(tdatatheaders_senttheaders_settoutput(s>/opt/alt/python27/lib/python2.7/site-packages/paste/wsgilib.pyRHFs



sAThe app_iter response can only contain str (not unicode); got: %rsContent sent w/o headers!s
 iterable: %rNR&R`Ra(ii(tErrorRaiserRR RtstrturllibtunquotetitemstreplaceR=R5R1t
ValueErrorRcR'Rbt	TypeErrortargsR(R&tjointgetvalue(RFtpathtraise_on_wsgi_errorRGR<t
basic_environt_t	path_infotquerytfragmenttnametvaluetistreamRHRtste((RdReRfRgs>/opt/alt/python27/lib/python2.7/site-packages/paste/wsgilib.pyRst	

!




&RhcBs,eZd�Zd�Zd�Zd�ZRS(cCsdS(N((R"((s>/opt/alt/python27/lib/python2.7/site-packages/paste/wsgilib.pytflushpscCs|s
dStd|��dS(Ns%No errors should be written (got: %r)(Rb(R"R{((s>/opt/alt/python27/lib/python2.7/site-packages/paste/wsgilib.pytwritesscCstdt|���dS(Ns+No errors should be written (got lines: %s)(RbRC(R"tseq((s>/opt/alt/python27/lib/python2.7/site-packages/paste/wsgilib.pyt
writelinesyscCsdS(NRP((R"((s>/opt/alt/python27/lib/python2.7/site-packages/paste/wsgilib.pyRr}s(R,R-RR�R�Rr(((s>/opt/alt/python27/lib/python2.7/site-packages/paste/wsgilib.pyRhns			c	Os�t||�\}}}}t�}|rZ|jd�|j|j��|jd�n|j|d�x+|D]#\}}|jd||f�qrW|jd�|j|�|j�S(sx
    Runs the application interatively, wrapping `raw_interactive` but
    returning the output in a formatted way.
    sErrors:
s
----------end errors
s
s%s: %s
(RRR�tstripRr(	RptkwR`RaR@R<tfullRzR{((s>/opt/alt/python27/lib/python2.7/site-packages/paste/wsgilib.pyR�s	


cCs�g}|j�}|j�xA|D]9}t||�jdd�}|jd||f�q#W|jd�|jdd�}|r�|j|djt|���|jd�ndj|�}dd	tt	|��fg}|d
|�|gS(sl
    Application which simply dumps the current environment
    variables out as a plain text response.
    s
s
    s%s: %s
R_RPs
wsgi.inputsContent-Types
text/plainsContent-Lengths200 OK(sContent-Types
text/plain(
tkeystsortRiRmRctgettreadtintRqR5(RGRHRgR�tktvtcontent_lengthRa((s>/opt/alt/python27/lib/python2.7/site-packages/paste/wsgilib.pyR�s 


 
cCs0tjdtd�ddlm}|j|�S(Ns9wsgilib.send_file has been moved to paste.fileapp.FileAppii����(tfileapp(twarningstwarntDeprecationWarningtpasteR�tFileApp(tfilenameR�((s>/opt/alt/python27/lib/python2.7/site-packages/paste/wsgilib.pyR�s

cs�tjdtd�g�t��d���fd�}|||�}z"x|D]}�j|�qSWWdt|d�r�|j�nX�s��jd�nt	��dkr��jd�n�j�j
���S(s
    Runs application with environ and start_response, and captures
    status, headers, and body.

    Sends status and header, but *not* body.  Returns (status,
    headers, body).  Typically this is used like:
    
    .. code-block:: python

        def dehtmlifying_middleware(application):
            def replacement_app(environ, start_response):
                status, headers, body = capture_output(
                    environ, start_response, application)
                content_type = header_value(headers, 'content-type')
                if (not content_type
                    or not content_type.startswith('text/html')):
                    return [body]
                body = re.sub(r'<.*?>', '', body)
                return [body]
            return replacement_app

    sOwsgilib.capture_output has been deprecated in favor of wsgilib.intercept_outputicsA�rg�(n�j|��j|��|||��jS(N(RcR�(R`RaR8(RdRgRH(s>/opt/alt/python27/lib/python2.7/site-packages/paste/wsgilib.pytreplacement_start_response�s


NR&(R�R�R�RR1R�R(R&RcR5Rr(RGRHRFR�RR4((RdRgRHs>/opt/alt/python27/lib/python2.7/site-packages/paste/wsgilib.pyR�s$
	
cs�dk	r'�dkr'td��ng�t��d����fd�}|||�}�ddkr}dd|fSz"x|D]}�j|�q�WWdt|d�r�|j�nX�s��jd�nt��dkr��jd�n�j�j���S(s�
    Runs application with environ and captures status, headers, and
    body.  None are sent on; you must send them on yourself (unlike
    ``capture_output``)

    Typically this is used like:
    
    .. code-block:: python

        def dehtmlifying_middleware(application):
            def replacement_app(environ, start_response):
                status, headers, body = intercept_output(
                    environ, application)
                start_response(status, headers)
                content_type = header_value(headers, 'content-type')
                if (not content_type
                    or not content_type.startswith('text/html')):
                    return [body]
                body = re.sub(r'<.*?>', '', body)
                return [body]
            return replacement_app

    A third optional argument ``conditional`` should be a function
    that takes ``conditional(status, headers)`` and returns False if
    the request should not be intercepted.  In that case
    ``start_response`` will be called and ``(None, None, app_iter)``
    will be returned.  You must detect that in your code and return
    the app_iter, like:
    
    .. code-block:: python

        def dehtmlifying_middleware(application):
            def replacement_app(environ, start_response):
                status, headers, body = intercept_output(
                    environ, application,
                    lambda s, h: header_value(headers, 'content-type').startswith('text/html'),
                    start_response)
                if status is None:
                    return body
                start_response(status, headers)
                body = re.sub(r'<.*?>', '', body)
                return [body]
            return replacement_app
    s?If you provide conditional you must also provide start_responsecsj�dk	r9�||�r9�jd��|||�S�rIg�(n�j|��j|��jS(N(R1RcR�(R`RaR8(tconditionalRdRgRH(s>/opt/alt/python27/lib/python2.7/site-packages/paste/wsgilib.pyR�s



iNR&i(	R1RoRR�R(R&RcR5Rr(RGRFR�RHR�RR4((R�RdRgRHs>/opt/alt/python27/lib/python2.7/site-packages/paste/wsgilib.pyR�s(.		

tResponseHeaderDictcBseZd�ZRS(cOs*tjdtd�tj|||�dS(NsPThe class wsgilib.ResponseHeaderDict has been moved to paste.response.HeaderDicti(R�R�R�RR#(R"RpR�((s>/opt/alt/python27/lib/python2.7/site-packages/paste/wsgilib.pyR#3s
(R,R-R#(((s>/opt/alt/python27/lib/python2.7/site-packages/paste/wsgilib.pyR�1scsQ�j��jdd�����fd�}y�j|_WnnX|S(NR,R]cs*tjd��ftd��||�S(Ns,The function wsgilib.%s has been moved to %si(R�R�R�(RpR�(tnew_functnew_nametnew_path(s>/opt/alt/python27/lib/python2.7/site-packages/paste/wsgilib.pytreplacement=s


(t	func_nametfunc_globals(R�R�((R�R�R�s>/opt/alt/python27/lib/python2.7/site-packages/paste/wsgilib.pyt_warn_deprecated:s	R�R,t__main__(8R.t
paste.requestRRRRRRtpaste.responseRRRR	R
RRt	tracebackR
Rjt	cStringIORR)turlparseRR�t__all__tobjectRRRRR1RRERORRLR RRhRtproxyRRRRR�R�t_nametglobalst_funcR(R�R,tdoctestttestmod(((s>/opt/alt/python27/lib/python2.7/site-packages/paste/wsgilib.pyt<module>sV"			 '-'Y					2N		



Zerion Mini Shell 1.0