Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
contego / home / tvault / .virtenv / lib / python2.7 / site-packages / paste / wsgilib.pyc
Size: Mime:
ó
ª‹EYc@sÆdZddlmZddlmZmZmZddlmZmZm	Z	ddl
mZmZm
Z
mZddl
mZmZmZddlmZddlZddlZdd	lmZdd
lmZmZddlZddd
dddddddddddddddddgZdefd„ƒYZdefd „ƒYZ defd!„ƒYZ!defd"„ƒYZ"dd#„Z$d$efd%„ƒYZ%de&d&„Z'd'efd(„ƒYZ(d)e)d*„Z*d+efd,„ƒYZ+d-„Z,de,_-d.„Z.d/„Z/d0„Z0ddd1„Z1d2efd3„ƒYZ2d4„Z3xSeD]KZ4e5ƒe4Z6e7e6d5ƒrNe6j8d6e9krNe3e6ƒe5ƒe4<qNqNWe9d7krÂddl:Z:e:j;ƒndS(8s&
A module of many disparate routines.
iÿÿÿÿ(tprint_function(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(t	cStringIO(tunquoteturlsplitt	add_closetadd_start_closetcapture_outputtcatch_errorstcatch_errors_apptchained_app_itersRtdump_environtencode_unicode_app_iterRRRRR	tinteractivetintercept_outputRRtraw_interactivet	send_filecBsDeZdZd„Zd„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!((sB/home/tvault/.virtenv/lib/python2.7/site-packages/paste/wsgilib.pyt__init__%s		cCs|S(N((R$((sB/home/tvault/.virtenv/lib/python2.7/site-packages/paste/wsgilib.pyt__iter__+scCs
|jƒS(N(t__next__(R$((sB/home/tvault/.virtenv/lib/python2.7/site-packages/paste/wsgilib.pytnext.scCs
t|jƒS(N(R(R (R$((sB/home/tvault/.virtenv/lib/python2.7/site-packages/paste/wsgilib.pyR'2scCs9t|_t|jdƒr+|jjƒn|jƒdS(Ntclose(tTrueR#thasattrRR)R!(R$((sB/home/tvault/.virtenv/lib/python2.7/site-packages/paste/wsgilib.pyR)5s	cCs*|js&td|jdtjƒndS(NsgError: app_iter.close() was not called when finishing WSGI request. finalization function %s not calledtfile(R#tprintR!tsyststderr(R$((sB/home/tvault/.virtenv/lib/python2.7/site-packages/paste/wsgilib.pyt__del__;s	(	t__name__t
__module__t__doc__R%R&R(R'R)R0(((sB/home/tvault/.virtenv/lib/python2.7/site-packages/paste/wsgilib.pyRs					cBsDeZdZdd„Zd„Zd„ZeZd„Zd„Z	RS(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(	RRR R*tfirstt
start_funcR!R"R#(R$RR5R!((sB/home/tvault/.virtenv/lib/python2.7/site-packages/paste/wsgilib.pyR%Is				cCs|S(N((R$((sB/home/tvault/.virtenv/lib/python2.7/site-packages/paste/wsgilib.pyR&QscCs,|jr|jƒt|_nt|jƒS(N(R4R5R"R(R (R$((sB/home/tvault/.virtenv/lib/python2.7/site-packages/paste/wsgilib.pyR(Ts	
cCsKt|_t|jdƒr+|jjƒn|jdk	rG|jƒndS(NR)(R*R#R+RR)R!tNone(R$((sB/home/tvault/.virtenv/lib/python2.7/site-packages/paste/wsgilib.pyR)[s
	cCs*|js&td|jdtjƒndS(NsgError: app_iter.close() was not called when finishing WSGI request. finalization function %s not calledR,(R#R-R!R.R/(R$((sB/home/tvault/.virtenv/lib/python2.7/site-packages/paste/wsgilib.pyR0bs	N(
R1R2R3R6R%R&R(R'R)R0(((sB/home/tvault/.virtenv/lib/python2.7/site-packages/paste/wsgilib.pyRBs			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$R8titem((sB/home/tvault/.virtenv/lib/python2.7/site-packages/paste/wsgilib.pyR%ps	"cCs|S(N((R$((sB/home/tvault/.virtenv/lib/python2.7/site-packages/paste/wsgilib.pyR&uscCsjt|jƒdkr&|jdjƒSy|jdjƒSWn(tk
re|jjdƒ|jƒSXdS(Nii(tlenR8R(t
StopIterationtpop(R$((sB/home/tvault/.virtenv/lib/python2.7/site-packages/paste/wsgilib.pyR(xs
cCs…t|_d}xG|jD]<}y t|dƒr>|jƒnWqtjƒ}qXqW|rtj	|d|d|dƒndS(NR)iii(
R*R#R6R7R+R)R.texc_infotsixtreraise(R$tgot_excR ((sB/home/tvault/.virtenv/lib/python2.7/site-packages/paste/wsgilib.pyR)‚s	cCs*|js&td|jdtjƒndS(NsgError: app_iter.close() was not called when finishing WSGI request. finalization function %s not calledR,(R#R-R!R.R/(R$((sB/home/tvault/.virtenv/lib/python2.7/site-packages/paste/wsgilib.pyR0Žs	(R1R2R3R%R&R(R)R0(((sB/home/tvault/.virtenv/lib/python2.7/site-packages/paste/wsgilib.pyRis			
	cBsDeZdZejƒdd„Zd„Zd„ZeZd„Z	RS(s@
    Encodes an app_iterable's unicode responses as strings
    tstrictcCs.||_t|ƒ|_||_||_dS(N(RRR tencodingterrors(R$RRBRC((sB/home/tvault/.virtenv/lib/python2.7/site-packages/paste/wsgilib.pyR%šs		cCs|S(N((R$((sB/home/tvault/.virtenv/lib/python2.7/site-packages/paste/wsgilib.pyR&¡scCs@t|jƒ}t|tjƒr<|j|j|jƒ}n|S(N(R(R t
isinstanceR>t	text_typetencodeRBRC(R$tcontent((sB/home/tvault/.virtenv/lib/python2.7/site-packages/paste/wsgilib.pyR(¤scCs&t|jdƒr"|jjƒndS(NR)(R+RR)(R$((sB/home/tvault/.virtenv/lib/python2.7/site-packages/paste/wsgilib.pyR)«s(
R1R2R3R.tgetdefaultencodingR%R&R(R'R)(((sB/home/tvault/.virtenv/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.R=ttypetlistttuplet_wrap_app_iter(tapplicationtenvirontstart_responseterror_callbacktok_callbackR ((sB/home/tvault/.virtenv/lib/python2.7/site-packages/paste/wsgilib.pyR¯s
RLcBs#eZd„Zd„Zd„ZRS(cCsR||_t|ƒ|_||_||_t|jdƒrN|jj|_ndS(NR)(RRR RPRQR+R)(R$RRPRQ((sB/home/tvault/.virtenv/lib/python2.7/site-packages/paste/wsgilib.pyR%Æs			cCs|S(N((R$((sB/home/tvault/.virtenv/lib/python2.7/site-packages/paste/wsgilib.pyR&ÎscCs^y|jjƒSWnFtk
r=|jr7|jƒn‚n|jtjƒƒ‚nXdS(N(R R(R;RQRPR.R=(R$((sB/home/tvault/.virtenv/lib/python2.7/site-packages/paste/wsgilib.pyR(Ñs
	
(R1R2R%R&R((((sB/home/tvault/.virtenv/lib/python2.7/site-packages/paste/wsgilib.pyRLÄ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.R=RIRJRKR6t_wrap_app_iter_app(RMRNROterror_callback_appRQRRR ((sB/home/tvault/.virtenv/lib/python2.7/site-packages/paste/wsgilib.pyRÜs	

	RScBs&eZed„Zd„Zd„ZRS(cCsm||_||_||_t|ƒ|_||_||_||_t|jdƒri|jj	|_	ndS(NR)(
RNRORRR RTRQRRR+R)(R$RNRORRTRQRR((sB/home/tvault/.virtenv/lib/python2.7/site-packages/paste/wsgilib.pyR%õs						cCs|S(N((R$((sB/home/tvault/.virtenv/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)(R R(R;RQRRR+RR)RTRNROR.R=R(R$tnew_app_iterableR ((sB/home/tvault/.virtenv/lib/python2.7/site-packages/paste/wsgilib.pyR(s&
	
(R1R2t	ExceptionR%R&R((((sB/home/tvault/.virtenv/lib/python2.7/site-packages/paste/wsgilib.pyRSós	tcsßd|kstdƒ‚|r*tƒ}ntjƒ}i
dd6dd6dd6dd	6d
d6dd
6d%d6dd6tjƒd6|d6td6td6td6}|r	tt|ƒƒ\}}}}}	t|ƒ}t|ƒt|ƒ}}||d<|r	||d<q	nx6|jƒD](\}
}|
j	ddƒ}
|||
<qWd	|krkd|krk|d	|d<n|d}t
|tƒrªtj|ƒ|d<t|ƒ|d<ni‰g‰g‰g‰d!‡‡‡‡fd†}
|||
ƒ}z¬yixb|D]Z}t
|tjƒs$td|ƒ‚nˆjtƒˆsFtdƒ‚nˆj|ƒqùWWn<tk
r–}|jdd |f|jd|_‚nXWd!t|d"ƒr·|jƒnXˆd#ˆd$djˆƒ|jƒfS(&s5
    Runs the application in a fake environment.
    t	path_infosargument list changedtGETtREQUEST_METHODRWtSCRIPT_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_LENGTHcs||r?z,ˆr1tj|d|d|dƒnWdd}XnˆrTtdƒ‚nˆjtƒ|ˆd<|ˆd<ˆjS(Niiis$Headers already set and no exc_info!tstatustheaders(R>R?R6tAssertionErrortappendR*(RhRiR=(tdatatheaders_senttheaders_settoutput(sB/home/tvault/.virtenv/lib/python2.7/site-packages/paste/wsgilib.pyROKs&



sCThe app_iter response can only contain bytes (not unicode); got: %rsContent sent w/o headers!s
 iterable: %rNR)RhRi(ii(RjtErrorRaiserR>tBytesIOR"RtstrRtitemstreplaceRDtbytesR:R6tbinary_typet
ValueErrorRkR*t	TypeErrortargsR+R)tjointgetvalue(RMtpathtraise_on_wsgi_errorRNRCt
basic_environt_RXtquerytfragmenttnametvaluetistreamROR tste((RlRmRnRosB/home/tvault/.virtenv/lib/python2.7/site-packages/paste/wsgilib.pyRsv

!




&RpcBs,eZd„Zd„Zd„Zd„ZRS(cCsdS(N((R$((sB/home/tvault/.virtenv/lib/python2.7/site-packages/paste/wsgilib.pytflushuscCs|s
dStd|ƒ‚dS(Ns%No errors should be written (got: %r)(Rj(R$Rƒ((sB/home/tvault/.virtenv/lib/python2.7/site-packages/paste/wsgilib.pytwritexscCstdt|ƒƒ‚dS(Ns+No errors should be written (got lines: %s)(RjRJ(R$tseq((sB/home/tvault/.virtenv/lib/python2.7/site-packages/paste/wsgilib.pyt
writelines~scCsdS(NRW((R$((sB/home/tvault/.virtenv/lib/python2.7/site-packages/paste/wsgilib.pyR{‚s(R1R2R‡RˆRŠR{(((sB/home/tvault/.virtenv/lib/python2.7/site-packages/paste/wsgilib.pyRpss			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
(RtStringIORˆtstripR{(	RytkwRhRiRGRCtfullR‚Rƒ((sB/home/tvault/.virtenv/lib/python2.7/site-packages/paste/wsgilib.pyR…s	


cCsg}t|jƒƒ}|jƒxA|D]9}t||ƒjddƒ}|jd||fƒq)W|jdƒ|jddƒ}|r»|j|djt|ƒƒƒ|jdƒndj	|ƒ}t
jrå|jdƒ}ndd
tt
|ƒƒfg}|d|ƒ|gS(
sl
    Application which simply dumps the current environment
    variables out as a plain text response.
    s
s
    s%s: %s
RgRWs
wsgi.inputtutf8sContent-Types
text/plainsContent-Lengths200 OK(sContent-Types
text/plain(RJtkeystsortRrRtRktgettreadtintRzR>tPY3RFR:(RNRORoRtktvtcontent_lengthRi((sB/home/tvault/.virtenv/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™((sB/home/tvault/.virtenv/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(RkRˆ(RhRiR=(RlRoRO(sB/home/tvault/.virtenv/lib/python2.7/site-packages/paste/wsgilib.pytreplacement_start_responseÔs


NR)(RšR›RœR‹R6RˆR+R)RkR:R{(RNRORMR R R9((RlRoROsB/home/tvault/.virtenv/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(R6RkRˆ(RhRiR=(tconditionalRlRoRO(sB/home/tvault/.virtenv/lib/python2.7/site-packages/paste/wsgilib.pyR s



iNR)i(	R6RxR‹RˆR+R)RkR:R{(RNRMR¡ROR R R9((R¡RlRoROsB/home/tvault/.virtenv/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$RyR((sB/home/tvault/.virtenv/lib/python2.7/site-packages/paste/wsgilib.pyR%:s
(R1R2R%(((sB/home/tvault/.virtenv/lib/python2.7/site-packages/paste/wsgilib.pyR¢8scsQˆj‰ˆjddˆ‰‡‡‡fd†}yˆj|_WnnX|S(NR1Recs*tjdˆˆftdƒˆ||ŽS(Ns,The function wsgilib.%s has been moved to %si(RšR›Rœ(RyR(tnew_functnew_nametnew_path(sB/home/tvault/.virtenv/lib/python2.7/site-packages/paste/wsgilib.pytreplacementDs


(t	func_nametfunc_globals(R£R¦((R£R¤R¥sB/home/tvault/.virtenv/lib/python2.7/site-packages/paste/wsgilib.pyt_warn_deprecatedAs	R¨R1t__main__(<R3t
__future__Rt
paste.requestRRRRRRtpaste.responseRRR	R
RRR
t	tracebackRR>R.t	six.movesRR‹tsix.moves.urllib.parseRRRšt__all__tobjectRRRRR6RRLRVRRSR"RRpRtproxyRRRRR¢R©t_nametglobalst_funcR+R¨R1tdoctestttestmod(((sB/home/tvault/.virtenv/lib/python2.7/site-packages/paste/wsgilib.pyt<module>sX"			#','Y					2N