Your IP : 216.73.216.61


Current Path : /opt/alt/python35/lib/python3.5/site-packages/raven/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib/python3.5/site-packages/raven/__pycache__/middleware.cpython-35.pyc



��Y
�@s�dZddlmZddlmZddlmZmZddlm	Z	m
Z
mZedd��ZGdd	�d	e�Z
Gd
d�de�ZdS)
z�
raven.middleware
~~~~~~~~~~~~~~~~~~~~~~~~

:copyright: (c) 2010-2012 by the Sentry Team, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
�)�absolute_import)�contextmanager)�Iterator�next)�get_current_url�get_headers�get_environccs�y	dVWn�ttfk
r&�Yn�tk
rG|j|��Ynetk
rh|j|��YnDtk
r�}z$|jdkr�|j|��WYdd}~XnXdS)Nr)�
StopIteration�
GeneratorExit�	Exception�handle_exception�KeyboardInterrupt�
SystemExit�code)�environ�client�e�r�A/opt/alt/python35/lib/python3.5/site-packages/raven/middleware.py�common_exception_handlings	




rc@sFeZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�ClosingIteratorz[
    An iterator that is implements a ``close`` method as-per
    WSGI recommendation.
    cCsC||_||_t|dd�|_t|�|_d|_dS)N�closeF)�sentryr�getattr�_close�iter�iterable�closed)�selfrrrrrr�__init__,s
		zClosingIterator.__init__cCs|S)Nr)rrrr�__iter__3szClosingIterator.__iter__cCsTy.t|j|j��t|j�SWdQRXWntk
rO|j��YnXdS)N)rrrrrr	r)rrrr�__next__6s

zClosingIterator.__next__cCs~|jr
dSz:|jdk	rFt|j|j��|j�WdQRXWd|jjjj�|jjjj�d|_XdS)NT)	rrrrrr�context�clearZtransaction)rrrrrBs	zClosingIterator.closeN)�__name__�
__module__�__qualname__�__doc__rr r!rrrrrr&s
rc@sLeZdZdZddd�Zdd�Zdd�Zdd	d
�ZdS)�Sentryz�
    A WSGI middleware which will attempt to capture any
    uncaught exceptions and send them to Sentry.

    >>> from raven.base import Client
    >>> application = Sentry(application, Client())
    NcCs;||_|dkr.ddlm}|�}||_dS)Nr)�Client)�applicationZ
raven.baser)r)rr*rr)rrrrXs
		zSentry.__init__cCsR|jj|j|��t||��|j||�}WdQRXt|||�S)N)rZhttp_context�get_http_contextrr*r)rrZstart_responserrrr�__call___szSentry.__call__cCsXd|jd�dt|dd�d|jd�dtt|��d	tt|��iS)
N�methodZREQUEST_METHOD�urlZstrip_querystringTZquery_stringZQUERY_STRING�headers�env)�getr�dictrr)rrrrrr+gs
zSentry.get_http_contextcCs
|jj�S)N)rZcaptureException)rrrrrrrszSentry.handle_exception)r$r%r&r'rr,r+rrrrrr(Os
r(N)r'�
__future__r�
contextlibrZraven.utils.compatrrZraven.utils.wsgirrrrr�objectr(rrrr�<module>s)