#NEWLINE# def get_braintree_account( self ) : #NEWLINE# #INDENT# 'Fetch or create a braintree account for this participant.\n        ' #NEWLINE# if ( not self . braintree_customer_id ) : #NEWLINE# #INDENT# customer = braintree . Customer . create ( { #NEWLINE# #INDENT# 'custom_fields' : { #NEWLINE# #INDENT# 'participant_id' : self . id , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } ) . customer #NEWLINE# r = self . db . one ( '\n                UPDATE participants\n                   SET braintree_customer_id=%s\n                 WHERE id=%s\n                   AND braintree_customer_id IS NULL\n             RETURNING id\n            ' , ( customer . id , self . id ) ) #NEWLINE# if ( not r ) : #NEWLINE# #INDENT# return self . get_braintree_account ( ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# customer = braintree . Customer . find ( self . braintree_customer_id ) #NEWLINE# #UNINDENT# return customer