#NEWLINE# def load_backend( self , name , dumps = 'dumps' , loads = 'loads' , loads_exc = ValueError ) : #NEWLINE# #INDENT# "Load a JSON backend by name.\n\n        This method loads a backend and sets up references to that\n        backend's loads/dumps functions and exception classes.\n\n        :param dumps: is the name of the backend's encode method.\n          The method should take an object and return a string.\n          Defaults to 'dumps'.\n        :param loads: names the backend's method for the reverse\n          operation -- returning a Python object from a string.\n        :param loads_exc: can be either the name of the exception class\n          used to denote decoding errors, or it can be a direct reference\n          to the appropriate exception class itself.  If it is a name,\n          then the assumption is that an exception class of that name\n          can be found in the backend module's namespace.\n        :param load: names the backend's 'load' method.\n        :param dump: names the backend's 'dump' method.\n        :rtype bool: True on success, False if the backend could not be loaded.\n\n        " #NEWLINE# try : #NEWLINE# #INDENT# mod = __import__ ( name ) #NEWLINE# #UNINDENT# except ImportError : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# for attr in name . split ( '.' ) [ 1 : ] : #NEWLINE# #INDENT# mod = getattr ( mod , attr ) #NEWLINE# #UNINDENT# #UNINDENT# except AttributeError : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# if ( ( not self . _store ( self . _encoders , name , mod , dumps ) ) or ( not self . _store ( self . _decoders , name , mod , loads ) ) ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# if isinstance ( loads_exc , ( str , unicode ) ) : #NEWLINE# #INDENT# if ( not self . _store ( self . _decoder_exceptions , name , mod , loads_exc ) ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# self . _decoder_exceptions [ name ] = name #NEWLINE# #UNINDENT# self . _encoder_options [ name ] = ( [ ] , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# self . _decoder_options [ name ] = ( [ ] , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# self . _backend_names . append ( name ) #NEWLINE# self . _verified = True #NEWLINE# return True