#NEWLINE# def to_dict( self ) : #NEWLINE# #INDENT# 'Returns a dictionary of all errors within a document\n\n        Keys are field names or list indices and values are the\n        validation error messages, or a nested dictionary of\n        errors for an embedded document or list.\n        ' #NEWLINE# def build_dict( source ) : #NEWLINE# #INDENT# errors_dict = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# if ( not source ) : #NEWLINE# #INDENT# return errors_dict #NEWLINE# #UNINDENT# if isinstance ( source , dict ) : #NEWLINE# #INDENT# for ( field_name , error ) in source . iteritems ( ) : #NEWLINE# #INDENT# errors_dict [ field_name ] = build_dict ( error ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( isinstance ( source , ValidationError ) and source . errors ) : #NEWLINE# #INDENT# return build_dict ( source . errors ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return unicode ( source ) #NEWLINE# #UNINDENT# #UNINDENT# return errors_dict #NEWLINE# #UNINDENT# if ( not self . errors ) : #NEWLINE# #INDENT# return { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# return build_dict ( self . errors )