Ñò 0vKc@sdZddkZddkZddkZyddklZWn#ej oddklZnXddklZl Z l Z ddk l Z ddk l Z ddklZddkZdd gZd efd „ƒYZeƒZdefd „ƒYZd efd„ƒYZdefd„ƒYZdefd„ƒYZeeddeddddeddedd„Zed„Zd„Zd„Zeipdi eƒZ!xOe"e#e!ƒƒD];Z$e!e$i%ƒi&dƒodi'e!e$ƒe_Pq¼q¼W[$[!dS(s Error handler middleware iÿÿÿÿN(tStringIO(t formattert collectortreporter(twsgilib(trequest(t import_stringtErrorMiddlewarethandle_exceptiont _NoDefaultcBseZd„ZRS(cCsdS(Ns ((tself((s</usr/lib/python2.6/site-packages/weberror/errormiddleware.pyt__repr__s(t__name__t __module__R (((s</usr/lib/python2.6/site-packages/weberror/errormiddleware.pyR scBs\eZdZdeddeddddeddddd„Zd„Zd„Zd„Z RS(s³ Error handling middleware Usage:: error_catching_wsgi_app = ErrorMiddleware(wsgi_app) Settings: ``debug``: If true, then tracebacks will be shown in the browser. ``error_email``: an email address (or list of addresses) to send exception reports to ``error_log``: a filename to append tracebacks to ``show_exceptions_in_wsgi_errors``: If true, then errors will be printed to ``wsgi.errors`` (frequently a server error log, or stderr). ``from_address``, ``smtp_server``, ``error_subject_prefix``, ``smtp_username``, ``smtp_password``, ``smtp_use_tls``: variables to control the emailed exception reports ``error_message``: When debug mode is off, the error message to show to users. ``xmlhttp_key``: When this key (default ``_``) is in the request GET variables (not POST!), expect that this is an XMLHttpRequest, and the response should be more minimal; it should not be a complete HTML page. Environment Configuration: ``paste.throw_errors``: If this setting in the request environment is true, then this middleware is disabled. This can be useful in a testing situation where you don't want errors to be caught and transformed. ``paste.expected_exceptions``: When this middleware encounters an exception listed in this environment variable and when the ``start_response`` has not yet occurred, the exception will be re-raised instead of being caught. This should generally be set by middleware that may (but probably shouldn't be) installed above this middleware, and wants to get certain exceptions. Exceptions raised after ``start_response`` have been called are always caught since by definition they are no longer expected. cCsòddkl}||_|djo h}n|tjo|i|idƒƒ}n|tjo|i|idƒƒ}n|i|ƒ|_|djoC|idƒp-|idƒp|idƒp |idƒ}n|i|ƒ|_ ||_ ||_ |djoE|id ƒ}|djo%|i o|i d }qVd }qZn||_ |djo|id d ƒ}n||_ | p |idƒ|_| p |idƒ|_| p|i|idƒƒ|_| pd|_| djo|idƒ} n| |_|djo|iddƒ}n||_|p |idƒ}|oyt|tƒoi|iƒ}g}xT|D]H}ti|ƒ}t|ttifƒo |ƒ}n|i|ƒqŽWn|pg|_dS(Niÿÿÿÿ(t converterstdebugtshow_exceptions_in_wsgi_errorst error_emailt admin_emailtwebmaster_emailtsysadmin_emailterror_from_addressiserrors@localhostt smtp_servert localhostt smtp_usernamet smtp_passwordt smtp_use_tlstt error_messaget xmlhttp_keyt_terror_reporters(t paste.utilRt applicationtNonet NoDefaulttasbooltgett debug_modetaslistRt error_logRt from_addressRRRRterror_subject_prefixRRt isinstancet basestringtsplitRt eval_importttypettypest ClassTypetappendt reporters(R R!t global_confRRR(RR)RRRRR*RRR3Rtreporter_stringstreporter_stringR((s</usr/lib/python2.6/site-packages/weberror/errormiddleware.pyt__init__Ss`              "      cCsæ|idƒo|i||ƒSt|dtresponse((s</usr/lib/python2.6/site-packages/weberror/errormiddleware.pyt__call__”s&    cCs.t|ttfƒo|St||||ƒS(N(R+tlistttuplet CatchingIter(R RFRBRE((s</usr/lib/python2.6/site-packages/weberror/errormiddleware.pyR<³scCsÏt}|io6ti|ƒ}t|ƒi|iƒo t}qFnt||ddtd|id|i d|i d|i d|i d|i d |id |id |id |id |id|d|iƒS(Ns wsgi.errorsthtmlR&RR(Rterror_email_fromRRRRR*Rtsimple_html_errorR3(tFalseRRtparse_querystringtdictR%R9RR&RR(RR)RRRRR*RR3(R R>RBRNtget_vars((s</usr/lib/python2.6/site-packages/weberror/errormiddleware.pyR?¹s*             N( R R t__doc__R"R#ROR7RHR<R?(((s</usr/lib/python2.6/site-packages/weberror/errormiddleware.pyRs$6 4  R;cBseZd„Zd„ZRS(cCs||_t|_dS(N(RCROtresponse_started(R RC((s</usr/lib/python2.6/site-packages/weberror/errormiddleware.pyR7Ñs cGst|_|i|ŒdS(N(R9RTRC(R targs((s</usr/lib/python2.6/site-packages/weberror/errormiddleware.pyRHÕs (R R R7RH(((s</usr/lib/python2.6/site-packages/weberror/errormiddleware.pyR;Ðs RKcBs;eZdZd„Zd„Zd„Zd„Zd„ZRS(s­ A wrapper around the application iterator that will catch exceptions raised by the a generator, or by the close method, and display or report as necessary. cCs@||_t|ƒ|_||_||_||_t|_dS(N(t app_iterabletitert app_iteratorRBt start_checkerterror_middlewareROtclosed(R RFRBRYRZ((s</usr/lib/python2.6/site-packages/weberror/errormiddleware.pyR7ás     cCs|S(N((R ((s</usr/lib/python2.6/site-packages/weberror/errormiddleware.pyt__iter__éscCst|i|if}|io t‚ny|iiƒSWnÆtj o4t|_|iƒ}|dj o|St‚nˆt|_|iƒ}t i ƒ}|ii ||iƒ}|dj o|d|7}n|i ip|i ddg|ƒn|SXdS(Ns$
Error in .close():
%ss500 Internal Server Errors content-types text/html(s content-types text/html(R:RZRBR[t StopIterationRXtnextR9t_closeR"R=R>R?RYRT(R RDtclose_responseR>RG((s</usr/lib/python2.6/site-packages/weberror/errormiddleware.pyR^ìs4               cCs|ip|iƒndS(N(R[R_(R ((s</usr/lib/python2.6/site-packages/weberror/errormiddleware.pytclose s cCsZt|idƒpdSy|iiƒdSWn&|iitiƒ|iƒ}|SXdS(s"Close and return any error messageRaN( thasattrRVR"RaRZR?R=R>RB(R R`((s</usr/lib/python2.6/site-packages/weberror/errormiddleware.pyR_s  (R R RSR7R\R^RaR_(((s</usr/lib/python2.6/site-packages/weberror/errormiddleware.pyRKÙs    R:cBs^eZdZd„Zd„Zhdd 6dd6dd6dd6d d6d d6d d6d d6ZRS(sThis is a supplement used to display standard WSGI information in the traceback. Additional configuration information can be added under a Configuration section by populating the environ['weberror.config'] variable with a dictionary to include. cCs(||_||_ti|ƒ|_dS(N(t middlewareRBRt construct_urlt source_url(R RcRB((s</usr/lib/python2.6/site-packages/weberror/errormiddleware.pyR7(s  c CsZh}h}|dt error_streamRLR&RR(RRMRRRRR*RRNR3treportedtexc_datat extra_datatreptrep_errt return_errort error_htmlt head_htmltmsgt err_report((s</usr/lib/python2.6/site-packages/weberror/errormiddleware.pyRSs„!              cCsy|i|ƒWnetƒ}tid|ƒ|o$dtit|ƒƒ|iƒfSdt|ƒ|iƒfSnXdSdS(NR}sw

Additionally an error occurred while sending the %s report:

%s

s>Additionally an error occurred while sending the %s report: %sR(treportRt tracebackt print_exctcgitescapetstrtgetvalue(R’RRLtoutput((s</usr/lib/python2.6/site-packages/weberror/errormiddleware.pyR…Às !cCsd|||fS(Ns” Server Error %s

Server Error

%s %s ((R–t exceptionRf((s</usr/lib/python2.6/site-packages/weberror/errormiddleware.pyRŒÔs cKst|d||S(NR4(R(tappR4tkw((s</usr/lib/python2.6/site-packages/weberror/errormiddleware.pytmake_error_middlewareâstSettings((RSR=RšRœt cStringIORt ImportErrortweberrorRRRtpasteRRR RR0t__all__tobjectR R#RR;RKR:R9ROR"RR…RŒR¤t splitlinest doc_linestrangetlentitstript startswithtjoin(((s</usr/lib/python2.6/site-packages/weberror/errormiddleware.pytsV      µ F4 `