%PDF- %PDF-
Mini Shell

Mini Shell

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

�
a�Nc@s�dZddlZddlZddlZddlZddlmZddlZddlZddl	Z	ddl
Z
ddlmZm
Z
mZddlmZddlmZddlmZddlmZdd	lmZdd
lmZddlZdZd�Zed
�Zd�Zd�Zd�Zd�Zeje e	j	���Z!d�Z"de#fd��YZ$de#fd��YZ%de
j&fd��YZ'd�Z(d�Z)d�Z*d�Z+dZ,dd�Z.dS(s�
Exception-catching middleware that allows interactive debugging.

This middleware catches all unexpected exceptions.  A normal
traceback, like produced by
``paste.exceptions.errormiddleware.ErrorMiddleware`` is given, plus
controls to see local variables and evaluate expressions in a local
context.

This can only be used in single-process environments, because
subsequent requests must go back to the same process that the
exception originally occurred in.  Threaded or non-concurrent
environments both work.

This shouldn't be used in production in any way.  That would just be
silly.

If calling from an XMLHttpRequest call, if the GET variable ``_`` is
given then it will make the response more compact (and less
Javascripty), since if you use innerHTML it'll kill your browser.  You
can look for the header X-Debug-URL in your 500 responses if you want
to see the full debuggable traceback.  Also, this URL is printed to
``wsgi.errors``, so you can open it up in another browser window.
i����N(tStringIO(terrormiddlewaret	formattert	collector(twsgilib(t	urlparser(thttpexceptions(tregistry(trequest(tresponsei�cCs&|dkrdStjt|�d�S(s;
    Escape HTML characters, plus translate None to ''
    tiN(tNonetcgitescapetstr(tv((sO/opt/alt/python27/lib/python2.7/site-packages/paste/evalexception/middleware.pyt
html_quote/scCsn|rt|�}n|jdd�}tjdt|�}tjdt|�}tjdt|�}d|S(s�
    Quote a value for HTML, preserving whitespace (translating
    newlines to ``<br>`` and multiple spaces to use ``&nbsp;``).

    If ``quote`` is true, then the value will be HTML quoted first.
    s
s<br>
s()(  +)s(\n)( +)s^()( +)s<code>%s</code>(Rtreplacetretsubt
_repl_nbsp(Rtquote((sO/opt/alt/python27/lib/python2.7/site-packages/paste/evalexception/middleware.pytpreserve_whitespace7scCsKt|jd��dkrdS|jd�dt|jd��ddS(Niis&nbsp;t (tlentgroup(tmatch((sO/opt/alt/python27/lib/python2.7/site-packages/paste/evalexception/middleware.pyRFscs�fd�}|S(s\
    A simple middleware that catches errors and turns them into simple
    tracebacks.
    csky�||�SWnSt�}tjd|�|ddgtj��|j�}dt|�gSXdS(Ntfiles500 Server Errorscontent-types	text/htmls<h3>Error</h3><pre>%s</pre>(scontent-types	text/html(Rt	tracebackt	print_exctsystexc_infotgetvalueR(tenvirontstart_responsetouttres(tapplication(sO/opt/alt/python27/lib/python2.7/site-packages/paste/evalexception/middleware.pytsimplecatcher_appPs	
((R%R&((R%sO/opt/alt/python27/lib/python2.7/site-packages/paste/evalexception/middleware.pyt
simplecatcherKscCs
d�}|S(s=
    Turns a function or method into a WSGI application.
    cs�fd�}t|_|S(Ncs�t��dkr6�d}�d}�dg�n�\}}g���fd�}tj|�}t|�}|||�S(Niiiics�tj|dt�}tjidd6dd6�}||d<||d<��|j��}|jd�}|||j��|gS(Ntinclude_get_varss	text/htmlscontent-types200 OKtstatusR!theaders(Rtparse_formvarstTrueR	t
HeaderDicttmixedtpoptheaderitems(R!R"tformR*R$R)(targstfunc(sO/opt/alt/python27/lib/python2.7/site-packages/paste/evalexception/middleware.pyR%ms	



(RRtmake_middlewareR'(R2R!R"R%tapp(R3(R2sO/opt/alt/python27/lib/python2.7/site-packages/paste/evalexception/middleware.pytwsgiapp_wrappercs

(R,texposed(R3R6((R3sO/opt/alt/python27/lib/python2.7/site-packages/paste/evalexception/middleware.pyt	decoratorbs	((R8((sO/opt/alt/python27/lib/python2.7/site-packages/paste/evalexception/middleware.pytwsgiapp^s	cs�fd�}|S(s�
    A decorator (meant to be used under ``wsgiapp()``) that resolves
    the ``debugcount`` variable to a ``DebugInfo`` object (or gives an
    error if it can't be found).
    cs�y�d|krtd��n|jd�}yt|�}Wntk
r\td��nX||jkrtd|��n|j|}�|d||�SWn,tk
r�}d|dd<d	t|�SXdS(
Nt
debugcounts'You must provide a debugcount parametersBad value for debugcounts0Debug %s no longer found (maybe it has expired?)t
debug_infos500 Server ErrorR*R)s#<html>There was an error: %s</html>(t
ValueErrorR/tinttdebug_infosR(tselfR1R:R;te(R3(sO/opt/alt/python27/lib/python2.7/site-packages/paste/evalexception/middleware.pytdebug_info_replacement�s"


((R3RA((R3sO/opt/alt/python27/lib/python2.7/site-packages/paste/evalexception/middleware.pytget_debug_info�scCs0d|kr|dStj�|d<}|SdS(s?
    Return the unique debug count for the current request
    spaste.evalexception.debug_countN(t
debug_countertnext(R!RD((sO/opt/alt/python27/lib/python2.7/site-packages/paste/evalexception/middleware.pytget_debug_count�st
EvalExceptioncBs�eZddd�Zd�Zd�Zd�Zee_d�Z	ee	_d�Z
ee
_d�Zee_d�Zd�Z
e�ee
��Z
d	�Ze�ee��Zd
�Zd�ZRS(
cCsU||_i|_|dkrH|dkr3d}qH|jdd�}n||_dS(Nt_txmlhttp_key(R%R>RtgetRH(R?R%tglobal_confRH((sO/opt/alt/python27/lib/python2.7/site-packages/paste/evalexception/middleware.pyt__init__�s			cCsI||d<|jdd�jd�r5|j||�S|j||�SdS(Nspaste.evalexceptiont	PATH_INFOR
s/_debug/(RIt
startswithtdebugtrespond(R?R!R"((sO/opt/alt/python27/lib/python2.7/site-packages/paste/evalexception/middleware.pyt__call__�s
cCs�tj|�}t||d�}|sYtjd|tj|�f�}|j||�St|dt	�s�tj
d|�}|j||�S|||�S(Ns%r not found when parsing %rR7s%r not allowed(Rt
path_info_poptgetattrRRtHTTPNotFoundRt
construct_urltwsgi_applicationtFalset
HTTPForbidden(R?R!R"t	next_parttmethodtexc((sO/opt/alt/python27/lib/python2.7/site-packages/paste/evalexception/middleware.pyRN�s
cCs7tjtjjtjjt�d��}|||�S(s?
        Static path where images and other files live
        tmedia(RtStaticURLParsertostpathtjointdirnamet__file__(R?R!R"R5((sO/opt/alt/python27/lib/python2.7/site-packages/paste/evalexception/middleware.pyR[�s$cCs7tjtjjtjjt�d��}|||�S(s2
        Static path where MochiKit lives
        tmochikit(RR\R]R^R_R`Ra(R?R!R"R5((sO/opt/alt/python27/lib/python2.7/site-packages/paste/evalexception/middleware.pyRb�s$cCsa|ddg�g}|jj�}|jd��g|D]}|j�^q<}t|�gS(s[
        Returns a JSON-format summary of all the cached
        exception reports
        s200 OKsContent-typestext/x-jsoncSst|j|j�S(N(tcmptcreated(tatb((sO/opt/alt/python27/lib/python2.7/site-packages/paste/evalexception/middleware.pyt<lambda>�s(sContent-typestext/x-json(R>tvaluestsorttjsontrepr(R?R!R"tdatatitemstitem((sO/opt/alt/python27/lib/python2.7/site-packages/paste/evalexception/middleware.pytsummary�scCs\ttj|��}||jkr?|ddg�d|gS|j|}|j||�S(s,
        View old exception reports
        s500 Server ErrorsContent-types	text/htmlsHTraceback by id %s does not exist (maybe the server has been restarted?)(sContent-types	text/html(R=RRQR>RU(R?R!R"tidR;((sO/opt/alt/python27/lib/python2.7/site-packages/paste/evalexception/middleware.pytview�s

cCs|d|S(Ns/_debug/view/%s((R?R!t	base_pathtcount((sO/opt/alt/python27/lib/python2.7/site-packages/paste/evalexception/middleware.pyt
make_view_url�scKsm|jt|��}|jj}|rVtjj|j�t|�}tjj	�nd}t
||�|S(Ns
No local vars(tframeR=ttb_frametf_localsRtrestorertrestoration_begintcountert
make_tabletrestoration_endt
input_form(R?ttbidR;tkwRutvarst
local_vars((sO/opt/alt/python27/lib/python2.7/site-packages/paste/evalexception/middleware.pyt
show_framescKs�|j�sdS|j�d}|jt|��}|jj}|jj}tj||�}t	j
j|j�|j
|�}	t	j
j�tj|�}
dt|
dt�t|	�fS(NR
s
sD<code style="color: #060">&gt;&gt;&gt;</code> <code>%s</code><br>
%sR(tstriptrstripRuR=RvRwt	f_globalstevalcontexttEvalContextRRxRyRzt	exec_exprR|Rtstr2htmlRRV(R?R~R;tinputRRuR�t	glob_varstcontexttoutputt
input_html((sO/opt/alt/python27/lib/python2.7/site-packages/paste/evalexception/middleware.pyt
exec_inputs
cs.|jd�r|j|��Stj|dtdt�}t|d<g�d��fd�}y\tj||f}|j||�}zt	|�}|SWdt
|d�r�|j�nXWnltj
�}x3|jdg�D]}	t|d|	�r��q�q�Wtjj|�t|�}
|j|||
�}�sidg}|jd
|f��d||�n|djd
|�tj|�}
t|
||
|||�}||j|
<|jrtj|�}t|�j|j�rtj|�}
tj|
dtdtdt�}|gSn|j �SXdS(Nspaste.throw_errorstwith_path_infotwith_query_stringcs2y�|||�SWn
�nX�jt�dS(N(tappendR,(R)R*R(R"tstarted(sO/opt/alt/python27/lib/python2.7/site-packages/paste/evalexception/middleware.pytdetect_start_response)s
tclosespaste.expected_exceptionsiscontent-types	text/htmlsX-Debug-URLs500 Internal Server Errorswsgi.errorss
Debug at: %s
tinclude_hidden_framestinclude_reusabletshow_extra_data(scontent-types	text/html(!RIR%RRTRVR,RRt
SupplementtlistthasattrR�RRt
isinstanceRRxtsave_registry_stateRERtR�twriteRtcollect_exceptiont	DebugInfoR>RHRtparse_querystringtdictRtformat_htmltcontent(R?R!R"RrR�t__traceback_supplement__tapp_itertreturn_iterRtexpectedRstview_uriR*texc_dataR;tget_varsthtml((R"R�sO/opt/alt/python27/lib/python2.7/site-packages/paste/evalexception/middleware.pyRO"sV	

	

	
c	Csht}|jrBtj|�}t|�j|j�rBt}qBntj||ddtdtd|�S(Nswsgi.errorsR�t
debug_modetsimple_html_error(	RVRHRR�R�RIR,Rthandle_exception(R?RR!R�R�((sO/opt/alt/python27/lib/python2.7/site-packages/paste/evalexception/middleware.pytexception_handler_s	
N(t__name__t
__module__RRKRPRNR[R,R7RbRoRqRtR�R9RBR�ROR�(((sO/opt/alt/python27/lib/python2.7/site-packages/paste/evalexception/middleware.pyRF�s&
	
													=R�cBs>eZd�Zd�Zd�Zd�Zd�Zd�ZRS(c
Cs�||_||_||_||_||_tj�|_|\|_|_|_	d}g|_
d}|j	}	xd|	dk	r�tdks�|tkr�|	j
jjd�r�Pn|j
j|	�|	j}	|d7}quWdS(Niit__exception_formatter__(RzR�RrR!R�ttimeRdtexc_typet	exc_valuettbtframesRtlimitRvRwRIR�ttb_next(
R?RzRR�RrR!R�R�tnR�((sO/opt/alt/python27/lib/python2.7/site-packages/paste/evalexception/middleware.pyRKms"							'	cCsWi|jd6tjdtj|j��d6|jd6t|j�d6t|j�d6S(s2Return the JSON-able representation of this objectturis%cRdtcreated_timestamptexception_typet	exception(R�R�tstrftimetgmtimeRdRR�R�(R?((sO/opt/alt/python27/lib/python2.7/site-packages/paste/evalexception/middleware.pyRj�s

cCsDx=|jD]}t|�|kr
|Sq
Wtd||jf�dS(NsNo frame by id %s found from %r(R�RpR<(R?R~Ru((sO/opt/alt/python27/lib/python2.7/site-packages/paste/evalexception/middleware.pyRu�s
cCs|ddg�|j�S(Ns200 OKscontent-types	text/html(scontent-types	text/html(R�(R?R!R"((sO/opt/alt/python27/lib/python2.7/site-packages/paste/evalexception/middleware.pyRU�scCsvt|j|j|j�}tjtj}||j�7}t|j	�}t
i|pYdd6|d6|d6}|gS(NR
t
repost_buttont	head_htmltbody(tformat_eval_htmlR�RrRzRt	error_cssthide_display_jsteval_javascripttmake_repost_buttonR!terror_template(R?R�R�R�tpage((sO/opt/alt/python27/lib/python2.7/site-packages/paste/evalexception/middleware.pyR��s
cCs$|jd}d||||jfS(Ns/_debugs�<script type="text/javascript" src="%s/media/MochiKit.packed.js"></script>
<script type="text/javascript" src="%s/media/debug.js"></script>
<script type="text/javascript">
debug_base = %r;
debug_count = %r;
</script>
(RrRz(R?Rr((sO/opt/alt/python27/lib/python2.7/site-packages/paste/evalexception/middleware.pyR��s
(R�R�RKRjRuRUR�R�(((sO/opt/alt/python27/lib/python2.7/site-packages/paste/evalexception/middleware.pyR�ks		
			tEvalHTMLFormattercBseZd�Zd�ZRS(cKs,tt|�j|�||_||_dS(N(tsuperR�RKRrRz(R?RrRzR((sO/opt/alt/python27/lib/python2.7/site-packages/paste/evalexception/middleware.pyRK�s	cCs0tjj|||�}|d|j|jfS(Ns�  <a href="#" class="switch_source" tbid="%s" onClick="return showFrame(this)">&nbsp; &nbsp; <img src="%s/_debug/media/plus.jpg" border=0 width=9 height=9> &nbsp; &nbsp;</a>(Rt
HTMLFormattertformat_source_lineR~Rr(R?tfilenameRutline((sO/opt/alt/python27/lib/python2.7/site-packages/paste/evalexception/middleware.pyR��s
	(R�R�RKR�(((sO/opt/alt/python27/lib/python2.7/site-packages/paste/evalexception/middleware.pyR��s	c		CsNt|t�r(|j�}|j�ng}d}x|D]�\}}|d7}t�}ytj||�Wn!tk
r�}|d|IJnXt|j��}t	|�dkr�|}|d }|d7}|d|d7}nt
j|�}|drd}nd	}|jd
|t|�t
|dt�f�q;Wdd
j|�S(Niis	Error: %sidsj<a class="switch_source" style="background-color: #999" href="#" onclick="return expandLong(this)">...</a>s%<span style="display: none">%s</span>is
 class="even"s class="odd"s[<tr%s style="vertical-align: top;"><td><b>%s</b></td><td style="overflow: auto">%s<td></tr>Rs<table>%s</table>s
(R�R�RmRiRtpprintt	ExceptionRR RRtmake_wrappableR�RRVR_(	RmtrowstitnametvalueR#R@t
orig_valuetattr((sO/opt/alt/python27/lib/python2.7/site-packages/paste/evalexception/middleware.pyR{�s6

	


		c	Cs�td|d|dt�}|j|�}td|d|dtdtdt�}|j|�}tj|dt�}|j|j�|j|j�kr�d|}nd}d||tj	|�fS(	NRrRzR�tshow_hidden_framesR�s�
    <br>
    <script type="text/javascript">
    show_button('full_traceback', 'full traceback')
    </script>
    <div id="full_traceback" class="hidden-data">
    %s
    </div>
        R
s�
    %s
    %s
    <br>
    <script type="text/javascript">
    show_button('text_version', 'text version')
    </script>
    <div id="text_version" class="hidden-data">
    <textarea style="width: 100%%" rows=10 cols=60>%s</textarea>
    </div>
    (
R�RVtformat_collected_dataR,Rtformat_textt
filter_framesR�RR
(	R�RrRztshort_formattertshort_ertlong_formattertlong_erttext_ertfull_traceback_html((sO/opt/alt/python27/lib/python2.7/site-packages/paste/evalexception/middleware.pyR��s$		
cCs/tj|�}|ddkr'd|SdSdS(NtREQUEST_METHODtGETsB<button onclick="window.location.href=%r">Re-GET Page</button><br>(RRTR(R!turl((sO/opt/alt/python27/lib/python2.7/site-packages/paste/evalexception/middleware.pyR�scCsdi|d6S(Ns~
<form action="#" method="POST"
 onsubmit="return submitInput($('submit_%(tbid)s'), %(tbid)s)">
<div id="exec-output-%(tbid)s" style="width: 95%%;
 padding: 5px; margin: 5px; border: 2px solid #000;
 display: none"></div>
<input type="text" name="input" id="debug_input_%(tbid)s"
 style="width: 100%%"
 autocomplete="off" onkeypress="upArrow(this, event)"><br>
<input type="submit" value="Execute" name="submitbutton"
 onclick="return submitInput(this, %(tbid)s)"
 id="submit_%(tbid)s"
 input-from="debug_input_%(tbid)s"
 output-to="exec-output-%(tbid)s">
<input type="submit" value="Expand"
 onclick="return expandInput(this)">
</form>
 R~((R~R;((sO/opt/alt/python27/lib/python2.7/site-packages/paste/evalexception/middleware.pyR}*ssE
<html>
<head>
 <title>Server Error</title>
 %(head_html)s
</head>
<body>

<div id="error-area" style="display: none; background-color: #600; color: #fff; border: 2px solid black">
<div id="error-container"></div>
<button onclick="return clearError()">clear this</button>
</div>

%(repost_button)s

%(body)s

</body>
</html>
cCs1|dkr!|jdd�}nt|d|�S(s�
    Wraps the application in an interactive debugger.

    This debugger is a major security hole, and should only be
    used during development.

    xmlhttp_key is a string that, if present in QUERY_STRING,
    indicates that the request is an XMLHttp request, and the
    Javascript/interactive debugger should not be returned.  (If you
    try to put the debugger somewhere with innerHTML, you will often
    crash the browser)
    RHRGN(RRIRF(R5RJRH((sO/opt/alt/python27/lib/python2.7/site-packages/paste/evalexception/middleware.pytmake_eval_exceptionSs
(/t__doc__RR]RRt	cStringIORR�t	itertoolsR�Rtpaste.exceptionsRRRtpasteRRRRRR	R�R�RR,RRR'R9RBRsR=RCREtobjectRFR�R�R�R{R�R�R}R�RR�(((sO/opt/alt/python27/lib/python2.7/site-packages/paste/evalexception/middleware.pyt<module>sF				"		
�E	!	*		'

Zerion Mini Shell 1.0