#NEWLINE# def record_ticket( self , record , data , hash , app_id ) : #NEWLINE# #INDENT# 'Records a log record as ticket.' #NEWLINE# s = self . session #NEWLINE# try : #NEWLINE# #INDENT# q = self . tickets . select ( ( self . tickets . c . record_hash == hash ) ) #NEWLINE# row = s . execute ( q ) . fetchone ( ) #NEWLINE# if ( row is None ) : #NEWLINE# #INDENT# row = s . execute ( self . tickets . insert ( ) . values ( record_hash = hash , level = record . level , channel = ( record . channel or u ( '' ) ) , location = ( u ( '%s:%d' ) % ( record . filename , record . lineno ) ) , module = ( record . module or u ( '<unknown>' ) ) , occurrence_count = 0 , solved = False , app_id = app_id ) ) #NEWLINE# ticket_id = row . inserted_primary_key [ 0 ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ticket_id = row [ 'ticket_id' ] #NEWLINE# #UNINDENT# s . execute ( self . occurrences . insert ( ) . values ( ticket_id = ticket_id , time = record . time , app_id = app_id , data = json . dumps ( data ) ) ) #NEWLINE# s . execute ( self . tickets . update ( ) . where ( ( self . tickets . c . ticket_id == ticket_id ) ) . values ( occurrence_count = ( self . tickets . c . occurrence_count + 1 ) , last_occurrence_time = record . time , solved = False ) ) #NEWLINE# s . commit ( ) #NEWLINE# #UNINDENT# except Exception : #NEWLINE# #INDENT# s . rollback ( ) #NEWLINE# raise #NEWLINE# #UNINDENT# s . remove ( )