def dispatch(self, json_data, **kwargs):
        '''
        Verifies that the passed json encoded string 
        is in the correct form according to the json-rpc spec
        and calls the appropriate method
        
        Checks:
         1. that the string encodes into a javascript Object (dictionary)
         2. that 'method' and 'params' are present
         3. 'method' must be a javascript String type
         4. 'params' must be a javascript Array type
         
        Returns:
         the JSON encoded response
        '''
        
        try:
            # attempt to do a json decode on the data
            jsondict = json.loads(json_data)
        except ValueError:
            return self._encode_result('', None, 
                    {'message': 'JSON decoding error', 
                     'code': JSONRPC_PARSE_ERROR})
        
        if not isinstance(jsondict, dict):
            # verify the json data was a javascript Object which gets decoded
            # into a python dictionary
            return self._encode_result('', None, 
                    {'message': 'Cannot decode to a javascript Object', 
                     'code': JSONRPC_BAD_CALL_ERROR})
        
        if not 'method' in jsondict or not 'params' in jsondict:
            # verify the dictionary contains the correct keys
            # for a proper jsonrpc call
            return self._encode_result(jsondict.get('id', ''), None, 
                    {'message': "JSONRPC requests must have the "+ \
                     "attributes 'method' and 'params'", 
                     'code': JSONRPC_BAD_CALL_ERROR})
        
        if not isinstance(jsondict['method'], StringTypes):
            return self._encode_result(jsondict.get('id', ''), None, 
                    {'message': 'method must be a javascript String', 
                     'code': JSONRPC_BAD_CALL_ERROR})
        
        if not isinstance(jsondict['params'], list):
            return self._encode_result(jsondict.get('id', ''), None, 
                    {'message': 'params must be a javascript Array', 
                     'code': JSONRPC_BAD_CALL_ERROR})
        
        
        if jsondict['method'] in self.methods:
            try:
                try:
                    result = self.methods[jsondict.get('method')] \
                                    (*jsondict.get('params'), **kwargs)
                except __HOLE__:
                    # Catch unexpected keyword argument error
                    result = self.methods[jsondict.get('method')] \
                                         (*jsondict.get('params'))
            except Exception, e:
                # this catches any error from the called method raising
                # an exception to the wrong number of params being sent
                # to the method.
                return self._encode_result(jsondict.get('id', ''), None, 
                            {'message': repr(e), 
                             'code': JSONRPC_SERVICE_ERROR})
            return self._encode_result(jsondict.get('id', ''), result, None)
        else:
            return self._encode_result(jsondict.get('id', ''), None, 
                    {'message': 'method "' + jsondict['method'] + \
                     '" is not supported',  
                     'code': JSONRPC_PROCEDURE_NOT_FOUND_ERROR})
dataset/ETHPy150Open fp7-ofelia/ocf/expedient/src/python/expedient/common/rpc4django/jsonrpcdispatcher.py/JSONRPCDispatcher.dispatch