Skip to content
This repository has been archived by the owner on Dec 21, 2020. It is now read-only.

Commit

Permalink
- support non positional arguments for all jsonrpc versions
Browse files Browse the repository at this point in the history
  • Loading branch information
jukart committed Feb 23, 2009
1 parent 49d9d7c commit 6af6496
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 28 deletions.
5 changes: 5 additions & 0 deletions CHANGES.txt
Expand Up @@ -2,6 +2,11 @@
CHANGES
=======

Branches/lovely
---------------

- support non positional arguments for all jsonrpc versions

Version 0.5.2dev (unreleased)
-----------------------------

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -25,7 +25,7 @@ def read(*rnames):

setup (
name='z3c.jsonrpc',
version='0.5.2dev',
version='0.5.2b3',
author = "Roger Ineichen and the Zope Community",
author_email = "zope-dev@zope.org",
description = "JSON RPC server and client implementation for Zope3",
Expand Down
29 changes: 2 additions & 27 deletions src/z3c/jsonrpc/publisher.py
Expand Up @@ -164,35 +164,11 @@ def processInputs(self):
# version for our request.
self.jsonVersion = data.get('version', self.jsonVersion)
self.jsonVersion = data.get('jsonrpc', self.jsonVersion)
if self.jsonVersion in ['1.0', '1.1']:
if self.jsonVersion in ['1.0', '1.1', '2.0']:
# json-rpc 1.0 and 1.1
args = params
# version 1.0 and 1.1 uses a list of arguments
for arg in args:
if isinstance(arg, dict):
# set every dict key value as form items and support at
# least ``:list`` and ``:tuple`` input field name postifx
# conversion.
for key, d in arg.items():
key = str(key)
pos = key.rfind(":")
if pos > 0:
match = self._typeFormat.match(key, pos + 1)
if match is not None:
key, type_name = key[:pos], key[pos + 1:]
if type_name == 'list' and not isinstance(d, list):
d = [d]
if type_name == 'tuple' and not isinstance(d, tuple):
d = tuple(d)
self.form[key] = d

elif self.jsonVersion == '2.0':
# version 2.0 uses a list or a dict as params. Process the list
# params here. This params get used as positional arguments in the
# method call.
if isinstance(params, list):
args = params
# now, look for keyword parameters, the old way
# version 1.0 and 1.1 uses a list of arguments
for arg in args:
if isinstance(arg, dict):
# set every dict key value as form items and support at
Expand All @@ -210,7 +186,6 @@ def processInputs(self):
if type_name == 'tuple' and not isinstance(d, tuple):
d = tuple(d)
self.form[key] = d

elif isinstance(params, dict):
# process the key/value pair params. This arguments get stored
# in the request.form argument and we skip it from method calls.
Expand Down

0 comments on commit 6af6496

Please sign in to comment.