#NEWLINE# def propagate_exchange( cursor , participant , route , error , amount ) : #NEWLINE# #INDENT# "Propagates an exchange's result to the participant's balance and the\n    route's status.\n    " #NEWLINE# route . update_error ( ( error or '' ) ) #NEWLINE# new_balance = cursor . one ( '\n        UPDATE participants\n           SET balance=(balance + %s)\n         WHERE id=%s\n     RETURNING balance\n    ' , ( amount , participant . id ) ) #NEWLINE# if ( ( amount < 0 ) and ( new_balance < 0 ) ) : #NEWLINE# #INDENT# raise NegativeBalance #NEWLINE# #UNINDENT# if hasattr ( route , 'set_attributes' ) : #NEWLINE# #INDENT# participant . set_attributes ( balance = new_balance )