B
aN @ sb d Z ddlZddlmZ ddlZddlmZ G dd deZG dd deZ edd d
fddZ
dS )
z
WSGI middleware
Captures any exceptions and prints a pretty report. See the `cgitb
documentation <http://python.org/doc/current/lib/module-cgitb.html>`_
for more.
N)StringIO)
convertersc @ s e Zd ZdS ) NoDefaultN)__name__
__module____qualname__ r r D/opt/alt/python37/lib/python3.7/site-packages/paste/cgitb_catcher.pyr s r c @ s8 e Zd ZdedddfddZdd Zdd Zd
d ZdS )CgitbMiddlewareN htmlc C sX || _ |d kri }|tkr$|d}t|tr8t|}|| _|| _t || _
|| _d S )Ndebug)appr get
isinstance
basestringr asbooldisplaylogdirintcontextformat)selfr global_confr r r r r r r __init__ s
zCgitbMiddleware.__init__c C sL y| ||}| ||S t }|ddg| | ||}|gS d S )Nz500 Internal Server Error)zcontent-typez text/html)r
catching_itersysexc_infoexception_handler)r environZstart_responseapp_iterr responser r r __call__) s zCgitbMiddleware.__call__c
c s |st d}y.x|D ]
}|V qW t|dr8d}| W nf | t |}|st|dry| W n( | t |}|d| 7 }Y nX |V Y nX d S )NFcloseTz$<hr noshade>Error in .close():<br>%s)
StopIterationhasattrr# r r r )r r r Zerror_on_closevr! Zclose_responser r r r 5 s*
zCgitbMiddleware.catching_iterc C s2 t }tj|| j| j| j| jd}|| | S )N)filer r r r )r cgitbZHookr r r r getvalue)r r r Z
dummy_filehookr r r r L s
z!CgitbMiddleware.exception_handler)r r r r r r"