def get_method_name(self, raw_post_data): ''' Gets the name of the method to be called given the post data and the format of the data ''' try: # attempt to do a json decode on the data jsondict = json.loads(raw_post_data) if not isinstance(jsondict, dict) or 'method' not in jsondict: return None else: return jsondict['method'] except ValueError: return None
def get_method_name(self, raw_post_data, request_format='xml'): ''' Gets the name of the method to be called given the post data and the format of the data ''' if request_format == 'xml': # xmlrpclib.loads could throw an exception, but this is fine # since _marshaled_dispatch would throw the same thing try: params, method = xmlrpclib.loads(raw_post_data) return method except Fault: return None else: try: # attempt to do a json decode on the data jsondict = json.loads(raw_post_data) if not isinstance(jsondict, dict) or 'method' not in jsondict: return None else: return jsondict['method'] except ValueError: return None
def get_method_name(self, raw_post_data, request_format='xml'): ''' Gets the name of the method to be called given the post data and the format of the data ''' if request_format == 'xml': # xmlrpclib.loads could throw an exception, but this is fine # since _marshaled_dispatch would throw the same thing try: params, method = xmlrpclib.loads(raw_post_data) return method except Exception: return None else: try: # attempt to do a json decode on the data jsondict = json.loads(raw_post_data) if not isinstance(jsondict, dict) or 'method' not in jsondict: return None else: return jsondict['method'] except ValueError: return None