diff --git a/gluon/contrib/simplejsonrpc.py b/gluon/contrib/simplejsonrpc.py index afdaec7d..4b620749 100644 --- a/gluon/contrib/simplejsonrpc.py +++ b/gluon/contrib/simplejsonrpc.py @@ -81,12 +81,13 @@ class JSONSafeTransport(JSONTransportMixin, SafeTransport): class ServerProxy(object): "JSON RPC Simple Client Service Proxy" - def __init__(self, uri, transport=None, encoding=None, verbose=0): + def __init__(self, uri, transport=None, encoding=None, verbose=0,version=None): self.location = uri # server location (url) self.trace = verbose # show debug messages self.exceptions = True # raise errors? (JSONRPCError) self.timeout = None self.json_request = self.json_response = '' + self.version = version # '2.0' for jsonrpc2 type, uri = urllib.splittype(uri) if type not in ("http", "https"): @@ -112,6 +113,8 @@ class ServerProxy(object): # build data sent to the service request_id = random.randint(0, sys.maxint) data = {'id': request_id, 'method': method, 'params': args, } + if self.version: + data['jsonrpc'] = self.version #mandatory key/value for jsonrpc2 validation else err -32600 request = json.dumps(data) # make HTTP request (retry if connection is lost)