Ńņ ŻĶKc@sądZddkZddkZddkZddkZddklZddkZddkZddk Z ddk Z ddk l Z l Z lZddklZddklZddklZddklZdd klZdd klZddkZd Zd „Zed „Zd„Zd„Zd„Zd„Zeie e i ƒƒƒZ!d„Z"de#fd„ƒYZ$de#fd„ƒYZ%de i&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(|djodStit|ƒdƒS(s; Escape HTML characters, plus translate None to '' tiN(tNonetcgitescapetstr(tv((sB/usr/lib/python2.6/site-packages/paste/evalexception/middleware.pyt html_quote/s cCsp|ot|ƒ}n|iddƒ}tidt|ƒ}tidt|ƒ}tidt|ƒ}d|S(sŹ Quote a value for HTML, preserving whitespace (translating newlines to ``
`` and multiple spaces to use `` ``). If ``quote`` is true, then the value will be HTML quoted first. s s
s()( +)s(\n)( +)s^()( +)s%s(Rtreplacetretsubt _repl_nbsp(Rtquote((sB/usr/lib/python2.6/site-packages/paste/evalexception/middleware.pytpreserve_whitespace7scCsMt|idƒƒdjodS|idƒdt|idƒƒddS(Niis t (tlentgroup(tmatch((sB/usr/lib/python2.6/site-packages/paste/evalexception/middleware.pyRFscs‡fd†}|S(s\ A simple middleware that catches errors and turns them into simple tracebacks. cskyˆ||ƒSWnStƒ}tid|ƒ|ddgtiƒƒ|iƒ}dt|ƒgSXdS(Ntfiles500 Server Errors content-types text/htmls

Error

%s
(s content-types text/html(Rt tracebackt print_exctsystexc_infotgetvalueR(tenvirontstart_responsetouttres(t application(sB/usr/lib/python2.6/site-packages/paste/evalexception/middleware.pytsimplecatcher_appPs   ((R%R&((R%sB/usr/lib/python2.6/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ˆƒdjo%ˆd}ˆd}ˆdg‰nˆ\}}g‰‡‡fd†}ti|ƒ}t|ƒ}|||ƒS(Niiiics„ti|dtƒ}tihdd6dd6ƒ}||d<||d<ˆˆ|iƒŽ}|idƒ}|||iƒƒ|gS(Ntinclude_get_varss text/htmls content-types200 OKtstatusR!theaders(Rtparse_formvarstTrueR t HeaderDicttmixedtpopt headeritems(R!R"tformR*R$R)(targstfunc(sB/usr/lib/python2.6/site-packages/paste/evalexception/middleware.pyR%ms      (RRtmake_middlewareR'(R2R!R"R%tapp(R3(R2sB/usr/lib/python2.6/site-packages/paste/evalexception/middleware.pytwsgiapp_wrappercs     (R,texposed(R3R6((R3sB/usr/lib/python2.6/site-packages/paste/evalexception/middleware.pyt decoratorbs ((R8((sB/usr/lib/python2.6/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). c sŪy¦d|jotdƒ‚n|idƒ}yt|ƒ}Wntj otdƒ‚nX||ijotd|ƒ‚n|i|}ˆ|d||SWn.tj o"}d|ddThere was an error: %s(t ValueErrorR/tintt debug_infosR(tselfR1R:R;te(R3(sB/usr/lib/python2.6/site-packages/paste/evalexception/middleware.pytdebug_info_replacement†s"  ((R3RA((R3sB/usr/lib/python2.6/site-packages/paste/evalexception/middleware.pytget_debug_info€scCs2d|jo |dStiƒ|d<}|SdS(s? Return the unique debug count for the current request spaste.evalexception.debug_countN(t debug_countertnext(R!RD((sB/usr/lib/python2.6/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„Z ee _d„Z d„Z eƒee ƒƒZ d „ZeƒeeƒƒZd „Zd „ZRS( cCsY||_h|_|djo-|djo d}qL|iddƒ}n||_dS(Nt_t xmlhttp_key(R%R>R tgetRH(R?R%t global_confRH((sB/usr/lib/python2.6/site-packages/paste/evalexception/middleware.pyt__init__§s     cCsa|d p td‚||d<|iddƒidƒo|i||ƒS|i||ƒSdS(Nswsgi.multiprocesssIThe EvalException middleware is not usable in a multi-process environmentspaste.evalexceptiont PATH_INFOR s/_debug/(tAssertionErrorRIt startswithtdebugtrespond(R?R!R"((sB/usr/lib/python2.6/site-packages/paste/evalexception/middleware.pyt__call__²s  cCs¼ti|ƒdjpt‚ti|ƒ}t||dƒ}|p3tid|ti|ƒfƒ}|i ||ƒSt|dt ƒp$ti d|ƒ}|i ||ƒS|||ƒS(Nt_debugs%r not found when parsing %rR7s%r not allowed( Rt path_info_popRMtgetattrR Rt HTTPNotFoundRt construct_urltwsgi_applicationtFalset HTTPForbidden(R?R!R"t next_parttmethodtexc((sB/usr/lib/python2.6/site-packages/paste/evalexception/middleware.pyRO¼s cCs7titiitiitƒdƒƒ}|||ƒS(s? Static path where images and other files live tmedia(RtStaticURLParsertostpathtjointdirnamet__file__(R?R!R"R5((sB/usr/lib/python2.6/site-packages/paste/evalexception/middleware.pyR]Ės$cCs7titiitiitƒdƒƒ}|||ƒS(s2 Static path where MochiKit lives tmochikit(RR^R_R`RaRbRc(R?R!R"R5((sB/usr/lib/python2.6/site-packages/paste/evalexception/middleware.pyRdŌs$cCsi|ddgƒg}|iiƒ}|id„ƒg}|D]}||iƒq@~}t|ƒgS(s[ Returns a JSON-format summary of all the cached exception reports s200 OKs Content-types text/x-jsoncSst|i|iƒS((tcmptcreated(tatb((sB/usr/lib/python2.6/site-packages/paste/evalexception/middleware.pytås(s Content-types text/x-json(R>tvaluestsorttjsontrepr(R?R!R"tdatatitemst_[1]titem((sB/usr/lib/python2.6/site-packages/paste/evalexception/middleware.pytsummaryŻs 'cCs^tti|ƒƒ}||ijo|ddgƒd|gS|i|}|i||ƒ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=RRSR>RW(R?R!R"tidR;((sB/usr/lib/python2.6/site-packages/paste/evalexception/middleware.pytviewźs   cCs |d|S(Ns/_debug/view/%s((R?R!t base_pathtcount((sB/usr/lib/python2.6/site-packages/paste/evalexception/middleware.pyt make_view_urlūscKso|it|ƒƒ}|ii}|o0tii|iƒt|ƒ}tii ƒnd}t ||ƒ|S(Ns No local vars( tframeR=ttb_frametf_localsRtrestorertrestoration_begintcountert make_tabletrestoration_endt input_form(R?ttbidR;tkwRxtvarst local_vars((sB/usr/lib/python2.6/site-packages/paste/evalexception/middleware.pyt show_frames  c Ksæ|iƒpdS|iƒd}|it|ƒƒ}|ii}|ii}ti||ƒ}t i i |i ƒ|i |ƒ} t i iƒti|ƒ} dt| dtƒt| ƒfS(NR s sD>>> %s
%sR(tstriptrstripRxR=RyRzt f_globalst evalcontextt EvalContextRR{R|R}t exec_exprRRtstr2htmlRRX( R?RR;tinputR‚RxRƒt glob_varstcontexttoutputt input_html((sB/usr/lib/python2.6/site-packages/paste/evalexception/middleware.pyt exec_inputs    c sQ|idƒo|i|ˆƒSti|dtdtƒ}t|dRMRHRtparse_querystringtdictRt format_htmltcontent(R?R!R"RuR—t__traceback_supplement__tapp_itert return_iterRtexpectedRvtview_uriR*texc_dataR;tget_varsthtml((R"R–sB/usr/lib/python2.6/site-packages/paste/evalexception/middleware.pyRP"sZ             c Cslt}|io6ti|ƒ}t|ƒi|iƒo t}qFnti||ddtdtd|ƒS(Ns wsgi.errorsRÆt debug_modetsimple_html_error( RXRHRR¤R„RIR,Rthandle_exception(R?RR!R±R®((sB/usr/lib/python2.6/site-packages/paste/evalexception/middleware.pytexception_handler_s  N(t__name__t __module__R RKRQROR]R,R7RdRrRtRwR…R9RBR’RPR³(((sB/usr/lib/python2.6/site-packages/paste/evalexception/middleware.pyRF„s&            =R£cBs>eZd„Zd„Zd„Zd„Zd„Zd„ZRS(c Csć||_||_||_||_||_tiƒ|_|\|_|_|_ d}g|_ d}|i } xj| dj o\t djp |t joB| i iidƒoPn|i i| ƒ| i} |d7}quWdS(Niit__exception_formatter__(R}R­RuR!R¬ttimeRftexc_typet exc_valuettbtframesR tlimitRyRzRIR•ttb_next( R?R}RR­RuR!R¬R¶tnRŗ((sB/usr/lib/python2.6/site-packages/paste/evalexception/middleware.pyRKms$       ' cCsWh|id6tidti|iƒƒd6|id6t|iƒd6t|iƒd6S(s2Return the JSON-able representation of this objectturis%cRftcreated_timestamptexception_typet exception(R¬R·tstrftimetgmtimeRfRRøR¹(R?((sB/usr/lib/python2.6/site-packages/paste/evalexception/middleware.pyRl‚s   cCsFx?|iD]}t|ƒ|jo|Sq Wtd||if‚dS(NsNo frame by id %s found from %r(R»RsR<(R?RRx((sB/usr/lib/python2.6/site-packages/paste/evalexception/middleware.pyRxŒs   cCs|ddgƒ|iƒS(Ns200 OKs content-types text/html(s content-types text/html(R§(R?R!R"((sB/usr/lib/python2.6/site-packages/paste/evalexception/middleware.pyRW”scCswt|i|i|iƒ}titi}||iƒ7}t|i ƒ}t h|pdd6|d6|d6}|gS(NR t repost_buttont head_htmltbody( tformat_eval_htmlR­RuR}Rt error_cssthide_display_jsteval_javascripttmake_repost_buttonR!terror_template(R?RÆRĘRÅtpage((sB/usr/lib/python2.6/site-packages/paste/evalexception/middleware.pyR§˜s cCs$|id}d||||ifS(Ns/_debugsŁ (RuR}(R?Ru((sB/usr/lib/python2.6/site-packages/paste/evalexception/middleware.pyRĖ£s (R“RµRKRlRxRWR§RĖ(((sB/usr/lib/python2.6/site-packages/paste/evalexception/middleware.pyR£ks     tEvalHTMLFormattercBseZd„Zd„ZRS(cKs,tt|ƒi|||_||_dS(N(tsuperRĻRKRuR}(R?RuR}R‚((sB/usr/lib/python2.6/site-packages/paste/evalexception/middleware.pyRK²s cCs0tii|||ƒ}|d|i|ifS(Ns­        (Rt HTMLFormattertformat_source_lineRRu(R?tfilenameRxtline((sB/usr/lib/python2.6/site-packages/paste/evalexception/middleware.pyRŅ·s  (R“RµRKRŅ(((sB/usr/lib/python2.6/site-packages/paste/evalexception/middleware.pyRϰs c CsVt|tƒo|iƒ}|iƒng}d}x |D]\}}|d7}tƒ}yti||ƒWn#tj o}|d|IJnXt|iƒƒ}t |ƒdjo0|}|d }|d7}|d|d7}nt i |ƒ}|do d}nd }|i d |t|ƒt |d tƒfƒq=Wd d i|ƒS(Niis Error: %sidsj...s%%sis class="even"s class="odd"s[%s%sRs%s
s (RŸR„RoRkRtpprintt ExceptionRR RRtmake_wrappableR•RRXRa( RotrowstitnametvalueR#R@t orig_valuetattr((sB/usr/lib/python2.6/site-packages/paste/evalexception/middleware.pyR~Įs8          c CsČtd|d|dtƒ}|i|ƒ}td|d|dtdtdtƒ}|i|ƒ}ti|dtƒ}|i|iƒ|i|iƒjod|}nd}d||ti |ƒfS( NRuR}Rštshow_hidden_framesR›s¼
%s
R sś %s %s
( RĻRXtformat_collected_dataR,Rt format_textt filter_framesR»R R ( R­RuR}tshort_formattertshort_ertlong_formattertlong_erttext_ertfull_traceback_html((sB/usr/lib/python2.6/site-packages/paste/evalexception/middleware.pyRČās$    cCs1ti|ƒ}|ddjo d|SdSdS(NtREQUEST_METHODtGETsB
(RRVR (R!turl((sB/usr/lib/python2.6/site-packages/paste/evalexception/middleware.pyRĢ s cCsdh|d6S(Ns~

R((RR;((sB/usr/lib/python2.6/site-packages/paste/evalexception/middleware.pyR€*ssE Server Error %(head_html)s %(repost_button)s %(body)s cCs3|djo|iddƒ}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(R RIRF(R5RJRH((sB/usr/lib/python2.6/site-packages/paste/evalexception/middleware.pytmake_eval_exceptionSs (/t__doc__RR_R Rt cStringIORRÕt itertoolsR·Rtpaste.exceptionsRRRtpasteRRRRRR R‰R¼RR,RRR'R9RBRvR=RCREtobjectRFR£RŃRĻR~RČRĢR€RĶR Rė(((sB/usr/lib/python2.6/site-packages/paste/evalexception/middleware.pytsF              "  ĘE ! *  '