Your IP : 18.218.5.216


Current Path : /opt/alt/python27/lib/python2.7/site-packages/raven/contrib/django/
Upload File :
Current File : //opt/alt/python27/lib/python2.7/site-packages/raven/contrib/django/client.pyc

�
��Yc@@s�dZddlmZddlZddlZddlmZddlm	Z	ddl
mZddlm
Z
ddlmZdd	lmZydd
lmZWn!ek
r�ddlmZnXddlmZdd
lmZmZddlmZddlmZm Z m!Z!ddl"m#Z#ddl$m%Z%m&Z&m'Z'ddl(m)Z)ddl*m+Z+dZ,edkr�d�Z-n	d�Z-de.fd��YZ/d�Z0e)d��Z1defd��YZ2dS( s�
raven.contrib.django.client
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:copyright: (c) 2010-2012 by the Sentry Team, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
i(tabsolute_importN(tVERSION(tsettings(tSuspiciousOperation(tHttpRequest(tTemplateSyntaxError(tMultiValueDict(tOrigin(tLoaderOrigin(tClient(tget_data_from_templatetget_host(tSentryMiddleware(tstring_typestbinary_typet	iterlists(t
RouteResolver(tget_headerstget_environt
get_client_ip(tonce(tbreadcrumbstDjangoClientii
cC@s
|j�S(N(tis_authenticated(trequest_user((sL/opt/alt/python27/lib/python2.7/site-packages/raven/contrib/django/client.pyR*scC@s|jS(N(R(R((sL/opt/alt/python27/lib/python2.7/site-packages/raven/contrib/django/client.pyR-st_FormatConvertercB@seZd�Zd�ZRS(cC@s||_g|_dS(N(t
param_mappingtparams(tselfR((sL/opt/alt/python27/lib/python2.7/site-packages/raven/contrib/django/client.pyt__init__3s	cC@s |jj|jj|��dS(Ns%s(RtappendRtget(Rtval((sL/opt/alt/python27/lib/python2.7/site-packages/raven/contrib/django/client.pyt__getitem__7s(t__name__t
__module__RR!(((sL/opt/alt/python27/lib/python2.7/site-packages/raven/contrib/django/client.pyR1s	cC@sg}t|t�rFt|�}|r=||}|j}qFd	}nx�|pRd
D]�}|dkru|jd�qSt|t�r�t|t�r�|jdd�}nt	|�dkr�|d d}n|jd|j
dd��qS|jt|��qSW||fS(NtNULLsutf-8treplaceiu…s'%s't's''(((t
isinstancetdictRRtNoneRR
RtdecodetlenR%trepr(tsqlRtrvtconvtparam((sL/opt/alt/python27/lib/python2.7/site-packages/raven/contrib/django/client.pyt
format_sql<s$
	 c@s�yddlm}Wn!tk
r7ddlm}nXy|j�|j�Wntk
rbdSXd���fd��d��fd�}��fd�}||_||_tj	d�dS(	s9If installed this causes Django's queries to be captured.i(t
CursorWrapperNc@s&��fd�}tjd|�dS(Nc@sMt���\}}|r.|t|�}n|ji|d6dd6�dS(Ntmessagetquerytcategory(R1ttupletupdate(tdatatreal_sqltreal_params(RR-(sL/opt/alt/python27/lib/python2.7/site-packages/raven/contrib/django/client.pyt	processorgs	R;(Rtrecord(tvendortaliaststarttdurationR-RR;((RR-sL/opt/alt/python27/lib/python2.7/site-packages/raven/contrib/django/client.pyt
record_sqlfs
c@s>tj�|}x'|D]}�||||||�qWdS(N(ttime(R=R>R?R-t
param_listR@R(RA(sL/opt/alt/python27/lib/python2.7/site-packages/raven/contrib/django/client.pytrecord_many_sqlss
c
@s`tj�}z�|||�SWd�|jjt|jdd�|tj�|||�XdS(NR>(RBtdbR=tgetattrR)(RR-RR?(treal_executeRA(sL/opt/alt/python27/lib/python2.7/site-packages/raven/contrib/django/client.pytexecutexs
c	@sStj�}z�|||�SWd�|jjt|jdd�|||�XdS(NR>(RBRER=RFR)(RR-RCR?(treal_executemanyRD(sL/opt/alt/python27/lib/python2.7/site-packages/raven/contrib/django/client.pytexecutemany�s
sdjango.db.backends(
tdjango.db.backends.utilsR2tImportErrortdjango.db.backends.utilRHRJtAttributeErrorR)Rt
ignore_logger(R2RHRJ((RGRIRDRAsL/opt/alt/python27/lib/python2.7/site-packages/raven/contrib/django/client.pytinstall_sql_hookVs 
	

	
		cB@sbeZejd�Ze�Zd�Zd�Zd�Z	d�Z
d�Zdd�Z
d�ZRS(	ssentry.errors.client.djangocO@s<|jdt�}tj|||�|r8|j�ndS(NRP(tpoptTrueR	RRP(RtargstkwargsRP((sL/opt/alt/python27/lib/python2.7/site-packages/raven/contrib/django/client.pyR�scC@st�dS(N(RP(R((sL/opt/alt/python27/lib/python2.7/site-packages/raven/contrib/django/client.pyRP�scC@s�it|j�d6}t|dd�}|dkr8|Sy�t|�}|sQ|S|j|d<t|d�r}|j|d<nt|d�r�|j�|d<nt|d�r�|j	|d<nWnt
k
r�nX|S(Nt
ip_addresstusertidtemailtget_usernametusername(RtMETARFR)RtpkthasattrRXRYRZt	Exception(Rtrequestt	user_infoRVt
authenticated((sL/opt/alt/python27/lib/python2.7/site-packages/raven/contrib/django/client.pyt
get_user_info�s&

cC@s�i}|j|�|d<y|j�}WnNtk
ry|j�rNd}nd}t|�}d|||jf}nX|jdkr)y
|j}Wq/tk
r%y
|j	}Wq&tk
r!y|j
p�d}Wntk
r�d}q"Xt|t�r"t
d�t|�D��}q"q&Xq/Xnd}|j}|jii|jd	6|d
6|jjd�d6|d
6t
|j�d6t
t|��d6t
t|��d6d6�|S(NRVthttpsthttps	%s://%s%stGETtHEADs
<unavailable>cs@s=|]3\}}|t|�dkr.|dn|fVqdS(iiN(R+(t.0tktv((sL/opt/alt/python27/lib/python2.7/site-packages/raven/contrib/django/client.pys	<genexpr>�stmethodturltQUERY_STRINGtquery_stringR8tcookiestheaderstenvR_(ReRf(Rbtbuild_absolute_uriRt	is_secureRtpathRjtbodyR^t
raw_post_datatPOSTR'RR(RR)R[R7RtCOOKIESRR(RR_tresultturitschemethostR8tenviron((sL/opt/alt/python27/lib/python2.7/site-packages/raven/contrib/django/client.pytget_data_from_request�sJ
	





!		
c	O@stt|�j||�}xN|j|�D]=}|jd�}|sLq+n|jd�r+t|d<q+q+W|jrdtj	kryIddl
m}|jj
�}|jp�|j}|djd|�Wqtk
ry|djdtj�Wqtk
rqXqXn|S(	Ntmodulesdjango.tin_appsdjango.contrib.sitesi(tSitettagstsite(tsuperRt	build_msgt_iter_framesRt
startswithtFalseR�RtINSTALLED_APPStdjango.contrib.sites.modelsR�tobjectstget_currenttnametdomaint
setdefaultR^tSITE_IDRN(	RRSRTR8tframeR~R�R�t	site_name((sL/opt/alt/python27/lib/python2.7/site-packages/raven/contrib/django/client.pyR��s&

c
K@s�d|kri|d<}n
|d}|dkrKttjdd�}nt|t�}|ry|j|j|��n|jd�re|dd}t	|d�s�t|t
�r�tt|dd�ttf�r�t|j
dt�s�t	|d�ret|dt|dd��}t|dd�}|dkrI|jjd	�n|jt||��qentt|�j||�}	|r�|	r�i|jd
|jj�d6|	d6|_n|	S(
NR8R_texc_infoitdjango_template_sourcetsourceittemplate_debugs,Unable to get template source from exceptiontprojectt
project_idRW(R)RFRtthreadR'RR7R}RR]RR6tlistR�RtloggertinfoR
R�RtcapturetremoteR�tsentry(
Rt
event_typeR_RTR8tis_http_requestt	exc_valueR�tdebugRx((sL/opt/alt/python27/lib/python2.7/site-packages/raven/contrib/django/client.pyR�s8
	cC@s|jj|j�S(N(tresolvertresolveRs(RR_((sL/opt/alt/python27/lib/python2.7/site-packages/raven/contrib/django/client.pytget_transaction_from_request4sN(R"R#tloggingt	getLoggerR�RR�RRPRbR}R�R)R�R�(((sL/opt/alt/python27/lib/python2.7/site-packages/raven/contrib/django/client.pyR�s					5	,(R(ii
(3t__doc__t
__future__RRBR�tdjangoRtDJANGO_VERSIONtdjango.confRtdjango.core.exceptionsRtdjango.httpRtdjango.templateRtdjango.utils.datastructuresRtdjango.template.baseRRLtdjango.template.loaderRt
raven.baseR	traven.contrib.django.utilsR
Rtraven.contrib.django.middlewareRtraven.utils.compatR
RRtraven.contrib.django.resolverRtraven.utils.wsgiRRRtraven.utilsRtravenRt__all__RtobjectRR1RPR(((sL/opt/alt/python27/lib/python2.7/site-packages/raven/contrib/django/client.pyt<module>s:
		7

?>