Skip to content

Feature - Add support for custom data in the JSON RPC request #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions jsonrpclib/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ class Config(object):
'.'.join([str(ver) for ver in sys.version_info[0:3]])
# User agent to use for calls.
_instance = None

#Allow extra parameters
extras = {}

@classmethod
def instance(cls):
Expand Down
3 changes: 3 additions & 0 deletions jsonrpclib/jsonrpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,13 +414,16 @@ def __init__(self, rpcid=None, version=None):
version = config.version
self.id = rpcid
self.version = float(version)
self.extras = config.extras

def request(self, method, params=[]):
if type(method) not in types.StringTypes:
raise ValueError('Method name must be a string.')
if not self.id:
self.id = random_id()
request = { 'id':self.id, 'method':method }
request.update(self.extras)

if params:
request['params'] = params
if self.version >= 2:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

distutils.core.setup(
name = "jsonrpclib",
version = "0.1.3",
version = "0.1.4",
packages = ["jsonrpclib"],
author = "Josh Marshall",
author_email = "catchjosh@gmail.com",
Expand Down