%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /opt/alt/python27/lib/python2.7/site-packages/paste/exceptions/
Upload File :
Create Path :
Current File : //opt/alt/python27/lib/python2.7/site-packages/paste/exceptions/errormiddleware.pyo

�
a�Nc@s�dZddlZddlZddlZyddlmZWn!ek
raddlmZnXddlmZm	Z	m
Z
ddlmZddlm
Z
ddgZd	efd
��YZe�Zdefd��YZdefd
��YZdefd��YZdefd��YZeeddeddddedded�
Zed�Zd�Zd�Zejje�ZxMee e��D]9Z!ee!j"�j#d�r�dj$ee!�e_Pq�q�W[![dS(s
Error handler middleware
i����N(tStringIO(t	formattert	collectortreporter(twsgilib(trequesttErrorMiddlewarethandle_exceptiont
_NoDefaultcBseZd�ZRS(cCsdS(Ns<NoDefault>((tself((sQ/opt/alt/python27/lib/python2.7/site-packages/paste/exceptions/errormiddleware.pyt__repr__s(t__name__t
__module__R
(((sQ/opt/alt/python27/lib/python2.7/site-packages/paste/exceptions/errormiddleware.pyRscBsYeZdZdeddeddddedddd�
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.

    c
Csddlm}||_|dkr.i}n|tkrU|j|jd��}n|tkr||j|jd��}n|j|�|_|dkr�|jd�p�|jd�p�|jd�p�|jd�}n|j|�|_	||_
||_|dkr|jd	d
�}n||_|dkrH|jdd�}n||_
|	pc|jd
�|_|
p{|jd�|_|p�|j|jd��|_|p�d|_|
dkr�|jd�}
n|
|_|dkr�|jdd�}n||_dS(Ni����(t
converterstdebugtshow_exceptions_in_wsgi_errorsterror_emailtadmin_emailtwebmaster_emailtsysadmin_emailterror_from_addressserrors@localhosttsmtp_servert	localhostt
smtp_usernamet
smtp_passwordtsmtp_use_tlstt
error_messagetxmlhttp_keyt_(t
paste.utilR
tapplicationtNonet	NoDefaulttasbooltgett
debug_modetaslistRt	error_logRtfrom_addressRRRRterror_subject_prefixRR(R	Rtglobal_confRRR&RR'RRRRR(RRR
((sQ/opt/alt/python27/lib/python2.7/site-packages/paste/exceptions/errormiddleware.pyt__init__QsB
						!	c	Cs�|jd�r|j||�St|d<yDt||f}t|�}|j||�}|j|||�SWn�tj�}zfx3|jdg�D]}t|d|�r��q�q�W|ddg|�|j	||�}|gSWdd}XnXdS(	s1
        The WSGI application interface.
        spaste.throw_errorsspaste.expected_exceptionsis500 Internal Server Errorscontent-types	text/htmlN(scontent-types	text/html(R#RtTruet
SupplementtResponseStartCheckertmake_catching_itertsystexc_infot
isinstancetexception_handlerR (	R	tenvirontstart_responset__traceback_supplement__t
sr_checkertapp_iterR0texpecttresponse((sQ/opt/alt/python27/lib/python2.7/site-packages/paste/exceptions/errormiddleware.pyt__call__�s(

cCs,t|ttf�r|St||||�S(N(R1tlistttupletCatchingIter(R	R7R3R6((sQ/opt/alt/python27/lib/python2.7/site-packages/paste/exceptions/errormiddleware.pyR.�scCs�t}|jrBtj|�}t|�j|j�rBt}qBnt||ddtd|jd|j	d|j
d|jd|jd|j
d	|jd
|jd|jd|jd
|jd|�
S(Nswsgi.errorsthtmlR$RR&Rterror_email_fromRRRRR(Rtsimple_html_error(tFalseRRtparse_querystringtdictR#R+RR$RR&RR'RRRRR(R(R	R0R3R@tget_vars((sQ/opt/alt/python27/lib/python2.7/site-packages/paste/exceptions/errormiddleware.pyR2�s(	
											N(
RRt__doc__R R!RAR*R:R.R2(((sQ/opt/alt/python27/lib/python2.7/site-packages/paste/exceptions/errormiddleware.pyRs"6%	 	R-cBseZd�Zd�ZRS(cCs||_t|_dS(N(R4RAtresponse_started(R	R4((sQ/opt/alt/python27/lib/python2.7/site-packages/paste/exceptions/errormiddleware.pyR*�s	cGst|_|j|�dS(N(R+RFR4(R	targs((sQ/opt/alt/python27/lib/python2.7/site-packages/paste/exceptions/errormiddleware.pyR:�s	(RRR*R:(((sQ/opt/alt/python27/lib/python2.7/site-packages/paste/exceptions/errormiddleware.pyR-�s	R=cBs;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_iteratorR3t
start_checkerterror_middlewareRAtclosed(R	R7R3RKRL((sQ/opt/alt/python27/lib/python2.7/site-packages/paste/exceptions/errormiddleware.pyR*�s				cCs|S(N((R	((sQ/opt/alt/python27/lib/python2.7/site-packages/paste/exceptions/errormiddleware.pyt__iter__�scCs�t|j|jf}|jr't�ny|jj�SWn�tk
rvt|_|j�}|dk	rm|St�n�t|_|j�}t
j�}|jj||j�}|dk	r�|d|7}n|j
js�|j
ddg|�n|SXdS(Ns$<hr noshade>Error in .close():<br>%ss500 Internal Server Errorscontent-types	text/html(scontent-types	text/html(R,RLR3RMt
StopIterationRJtnextR+t_closeR R/R0R2RKRF(R	R5tclose_responseR0R9((sQ/opt/alt/python27/lib/python2.7/site-packages/paste/exceptions/errormiddleware.pyRP�s4		
					
cCs|js|j�ndS(N(RMRQ(R	((sQ/opt/alt/python27/lib/python2.7/site-packages/paste/exceptions/errormiddleware.pytclose�s	cCsXt|jd�sdSy|jj�dSWn&|jjtj�|j�}|SXdS(s"Close and return any error messageRSN(	thasattrRHR RSRLR2R/R0R3(R	RR((sQ/opt/alt/python27/lib/python2.7/site-packages/paste/exceptions/errormiddleware.pyRQs
	(RRRER*RNRPRSRQ(((sQ/opt/alt/python27/lib/python2.7/site-packages/paste/exceptions/errormiddleware.pyR=�s			 	R,cBs^eZdZd�Zd�Zidd
6dd6dd6dd6d	d6d
d6dd6dd6ZRS(s^
    This is a supplement used to display standard WSGI information in
    the traceback.
    cCs(||_||_tj|�|_dS(N(t
middlewareR3Rt
construct_urlt
source_url(R	RUR3((sQ/opt/alt/python27/lib/python2.7/site-packages/paste/exceptions/errormiddleware.pyR*s		c	CsHi}i}|d<i}|d<dddddd	d
dg}x^|jj�D]M\}}|j�|kr�|r�|||<q�qP||krP|||<qPqPW|jd
dkr�|jd
|d
<ntgdD]}tt|j|��^q��}|j||d<|jj|d<d|jkrDt	|jd�|d<n|S(Ntextras
CGI VariablessWSGI Variablesspaste.configswsgi.errorss
wsgi.inputswsgi.multithreadswsgi.multiprocesss
wsgi.run_onceswsgi.versionswsgi.url_schemeiiswsgi processRt
Configuration(sextras
CGI Variables(sextrasWSGI Variables(ii(swsgi.multiprocessswsgi.multithreads
wsgi.run_once(sextraRY(
R3titemstupperR<tinttbooltprocess_combosRURRC(	R	tdatatcgi_varst	wsgi_varst	hide_varstnametvaluetkeyt	proc_desc((sQ/opt/alt/python27/lib/python2.7/site-packages/paste/exceptions/errormiddleware.pyt	extraDatas0		,sNon-concurrent serverit
MultithreadeditMultiprocesssMulti process AND threads (?)sNon-concurrent CGIsMultithread CGI (?)tCGIsMulti thread/process CGI (?)(iii(iii(iii(iii(iii(iii(iii(iii(RRRER*RgR^(((sQ/opt/alt/python27/lib/python2.7/site-packages/paste/exceptions/errormiddleware.pyR,
s		serrors@localhostRRcCsUt}tj|�}d}|r�tjd|d|d|d|	d|
d|d|�}t||d	|�}|r||7}q�t}n|r�tjd
|�}t||d	|�}|r�||7}q�t}n|rtjd|�}t||d	|�}|r||7}q7t}n|j	d|j
|jf�|r�|rs|rstj
|d
tdtdt�}t}q�|r�|r�tj
|d
tdt�}tjtj}t|||�}d}t}q�|
p�d}td|d�}nd}|r;|r;tj|dt�}|dddd7}|j	|�n|rQ|j	|�n|S(s�
    For exception handling outside of a web context

    Use like::

        import sys
        from paste.exceptions.errormiddleware import handle_exception
        try:
            do stuff
        except:
            handle_exception(
                sys.exc_info(), sys.stderr, html=False, ...other config...)

    If you want to report, but not fully catch the exception, call
    ``raise`` after ``handle_exception``, which (when given no argument)
    will reraise the exception.
    Rtto_addressesR'RRRRtsubject_prefixR>tfilenametfilesError - %s: %s
tinclude_hidden_framestinclude_reusabletshow_extra_datas�
            An error occurred.  See the error logs for more information.
            (Turn debug on to display exception reports here)
            tshow_hidden_framess
t-i<N(RARtcollect_exceptionRt
EmailReportertsend_reportR+tLogReportertFileReportertwritetexception_typetexception_valueRtformat_htmlt	error_cssthide_display_jsterror_templateR tformat_text(R0terror_streamR>R$RR&RR?RRRRR(RR@treportedtexc_datat
extra_datatreptrep_errtreturn_errort
error_htmlt	head_htmltmsgt
err_report((sQ/opt/alt/python27/lib/python2.7/site-packages/paste/exceptions/errormiddleware.pyR?sv		
			
			
			
		
cCsy|j|�Wnct�}tjd|�|rYdtjt|��|j�fSdt|�|j�fSnXdSdS(NRnsw
            <p>Additionally an error occurred while sending the %s report:

            <pre>%s</pre>
            </p>s>Additionally an error occurred while sending the %s report:
%sR(treportRt	tracebackt	print_exctcgitescapetstrtgetvalue(R�R�R>toutput((sQ/opt/alt/python27/lib/python2.7/site-packages/paste/exceptions/errormiddleware.pyRv�s	 cCsd|||fS(Ns�
    <html>
    <head>
    <title>Server Error</title>
    %s
    </head>
    <body>
    <h1>Server Error</h1>
    %s
    %s
    </body>
    </html>((R�t	exceptionRX((sQ/opt/alt/python27/lib/python2.7/site-packages/paste/exceptions/errormiddleware.pyR�scKst|d||�S(NR)(R(tappR)tkw((sQ/opt/alt/python27/lib/python2.7/site-packages/paste/exceptions/errormiddleware.pytmake_error_middleware�stSettings(%RER/R�R�t	cStringIORtImportErrortpaste.exceptionsRRRtpasteRRt__all__tobjectRR!RR-R=R,R+RAR RRvRR�t
splitlinest	doc_linestrangetlentitstript
startswithtjoin(((sQ/opt/alt/python27/lib/python2.7/site-packages/paste/exceptions/errormiddleware.pyt<module>sN
	�	F2W		

Zerion Mini Shell 1.0