๓ ฟ๖Yc@@skdZddlmZyddlmZWnek rCeZnXeZddl Z ddl Z ddl m Z m Z mZddlmZmZddlmZddlmZdd lmZdd lmZdd lmZdd lmZdd lm Z ddl!m"Z"m#Z#ddl$m%Z%e j&ƒZ'e'j(dƒZ)dd„Z+de,fd„ƒYZdS(sฃ raven.contrib.flask ~~~~~~~~~~~~~~~~~~~ :copyright: (c) 2010-2012 by the Sentry Team, see AUTHORS for more details. :license: BSD, see LICENSE for more details. i(tabsolute_import(t current_userN(trequestt current_apptg(tgot_request_exceptiontrequest_finished(tClientDisconnected(t setup_logging(tClient(tSentry(t SentryHandler(turlparse(t to_unicode(t get_headerst get_environ(tconvert_optionstlogging_configuredc C@sp|t|jdi|d6t|jjdgƒƒt|jgƒBd6|jjdgƒd6i|d6d6ƒS( NtdefaultstdsntSENTRY_INCLUDE_PATHSt include_pathstRAVEN_IGNORE_EXCEPTIONStignore_exceptionstapptextra(Rtconfigtsettgett import_name(t client_clsRR((sD/opt/alt/python27/lib/python2.7/site-packages/raven/contrib/flask.pyt make_client's R c B@s๒eZdZddededejded„ Z e d„ƒZ e j d„ƒZ d„Z d„Zd„Zd„Zd„Zd „Zdd „Zd „Zd „Zddddddd „Zd„Zd„Zd„Zd„Zd„ZRS(sฑ Flask application for Sentry. Look up configuration from ``os.environ['SENTRY_DSN']``:: >>> sentry = Sentry(app) Pass an arbitrary DSN:: >>> sentry = Sentry(app, dsn='http://public:secret@example.com/1') Pass an explicit client:: >>> sentry = Sentry(app, client=client) Automatically configure logging:: >>> sentry = Sentry(app, logging=True, level=logging.ERROR) Capture an exception:: >>> try: >>> 1 / 0 >>> except ZeroDivisionError: >>> sentry.captureException() Capture a message:: >>> sentry.captureMessage('hello, world!') By default, the Flask integration will do the following: - Hook into the `got_request_exception` signal. This can be disabled by passing `register_signal=False`. - Wrap the WSGI application. This can be disabled by passing `wrap_wsgi=False`. - Capture information from Flask-Login (if available). c C@s‡|r%t|tƒ r%tdƒ‚n||_||_||_||_||_||_||_ | |_ |rƒ|j |ƒndS(Ns&client should be an instance of Client( t isinstanceR t TypeErrorRtloggingtlogging_exclusionsRtclienttlevelt wrap_wsgitregister_signaltinit_app( tselfRR$RRR"R#R%R&R'((sD/opt/alt/python27/lib/python2.7/site-packages/raven/contrib/flask.pyt__init__es        cC@s/y tjSWntk rnXt|ddƒS(Nt_last_event_id(Rtsentry_event_idt ExceptiontgetattrtNone(R)((sD/opt/alt/python27/lib/python2.7/site-packages/raven/contrib/flask.pyt last_event_idws   cC@s.||_y |t_Wntk r)nXdS(N(R+RR,R-(R)tvalue((sD/opt/alt/python27/lib/python2.7/site-packages/raven/contrib/flask.pyR0s    cO@s*|js dS|jd|jdƒƒdS(Ntexc_info(R$tcaptureExceptionR(R)targstkwargs((sD/opt/alt/python27/lib/python2.7/site-packages/raven/contrib/flask.pythandle_exception‡s cC@s i}y|jd}Wntk r3|j}nX|rG||dRtR"tblinkertflaskRRRt flask.signalsRRtwerkzeug.exceptionsRt raven.confRt raven.baseR traven.middlewareR Rxtraven.handlers.loggingR traven.utils.compatR traven.utils.encodingR traven.utils.wsgiRRtraven.utils.confRt Namespacet raven_signalstsignalRR/Rtobject(((sD/opt/alt/python27/lib/python2.7/site-packages/raven/contrib/flask.pyts.