def _load_json_module():
 first_import_error = None
 for module_name in ['json', 'simplejson']:
  try:
   module = __import__(module_name, {}, {}, 'json')
   if (not hasattr(module, 'JSONEncoder')):
    message = ('json library "%s" is not compatible with ProtoRPC' % module_name)
    logging.warning(message)
    raise ImportError(message)
   else:
    return module
  except ImportError as err:
   if (not first_import_error):
    first_import_error = err
 logging.error('Must use valid json library (Python 2.6 json or simplejson)')
 raise first_import_error

def _load_json_module ( ) : first_import_error = None for module_name in [ 'json' , 'simplejson' ] : try : module = __import__ ( module_name , { } , { } , 'json' ) if ( not hasattr ( module , 'JSONEncoder' ) ) : message = ( 'json library "%s" is not compatible with ProtoRPC' % module_name ) logging . warning ( message ) raise ImportError ( message ) else : return module except ImportError as err : if ( not first_import_error ) : first_import_error = err logging . error ( 'Must use valid json library (Python 2.6 json or simplejson)' ) raise first_import_error
try to load a valid json module .