#NEWLINE# def _flatten_errors( self , params , parent = None ) : #NEWLINE# #INDENT# '\n            A modified version of the flatten_dictionary method above used\n            to coerce the structure holding errors returned by Braintree into\n            a flattened dictionary where the keys are the names of the fields\n            and the values the error messages, which can be directly used to\n            set the field errors on the Django form object for display in\n            templates.\n        ' #NEWLINE# data = OrderedDict ( ) #NEWLINE# for ( key , val ) in params . items ( ) : #NEWLINE# #INDENT# full_key = ( ( ( ( parent + '[' ) + key ) + ']' ) if parent else key ) #NEWLINE# if full_key . endswith ( '[errors]' ) : #NEWLINE# #INDENT# full_key = full_key [ : ( - len ( '[errors]' ) ) ] #NEWLINE# #UNINDENT# if isinstance ( val , dict ) : #NEWLINE# #INDENT# data . update ( self . _flatten_errors ( val , full_key ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( key == 'errors' ) : #NEWLINE# #INDENT# for error in val : #NEWLINE# #INDENT# data [ ( ( ( full_key + '[' ) + error [ 'attribute' ] ) + ']' ) ] = [ error [ 'message' ] ] #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# data [ full_key ] = [ val ] #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return params