Submit
Path:
~
/
/
proc
/
thread-self
/
root
/
opt
/
alt
/
python37
/
lib
/
python3.7
/
site-packages
/
paste
/
__pycache__
/
File Content:
cgitb_catcher.cpython-37.pyc
B a�N� � @ sb d Z ddlZddlmZ ddlZddlmZ G dd� de�ZG dd� de�Z edd d fdd�Z 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 Zdedddfdd�Zdd� Zdd � Zd d� ZdS )�CgitbMiddlewareN� �htmlc C sX || _ |d kri }|tkr$|�d�}t|t�r8t�|�}|| _|| _t |�| _ || _d S )N�debug)�appr �get� isinstance� basestringr �asbool�display�logdir�int�context�format)�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_iter�sys�exc_info�exception_handler)r �environZstart_response�app_iterr �responser r r �__call__) s zCgitbMiddleware.__call__c c s� |st �d}y.x|D ] }|V qW t|d�r8d}|�� W nf | �t�� |�}|s�t|d�r�y|�� W n( | �t�� |�}|d| 7 }Y nX |V Y nX d S )NF�closeTz$<hr noshade>Error in .close():<br>%s)� StopIteration�hasattrr# r r r )r r r Zerror_on_close�vr! 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_file�hookr r r r L s z!CgitbMiddleware.exception_handler)r r r r r r"