[Checkins] SVN: z3c.jsonrpc/trunk/ - support non positional arguments for all jsonrpc versions
Juergen Kartnaller
juergen at kartnaller.at
Mon Feb 23 08:58:39 EST 2009
Log message for revision 97165:
- support non positional arguments for all jsonrpc versions
There is now no distinction in handling method parameters for all supported
versions.
Changed:
U z3c.jsonrpc/trunk/CHANGES.txt
U z3c.jsonrpc/trunk/src/z3c/jsonrpc/publisher.py
-=-
Modified: z3c.jsonrpc/trunk/CHANGES.txt
===================================================================
--- z3c.jsonrpc/trunk/CHANGES.txt 2009-02-23 13:37:47 UTC (rev 97164)
+++ z3c.jsonrpc/trunk/CHANGES.txt 2009-02-23 13:58:39 UTC (rev 97165)
@@ -5,6 +5,10 @@
Version 0.5.2dev (unreleased)
-----------------------------
+ - support non positional arguments for all jsonrpc versions
+ There is now no distinction in handling method parameters for all supported
+ versions.
+
- for jsonrpc version 1.1 :
- must not provide "error" property in case of success
- must not provide "result" property in case of error
Modified: z3c.jsonrpc/trunk/src/z3c/jsonrpc/publisher.py
===================================================================
--- z3c.jsonrpc/trunk/src/z3c/jsonrpc/publisher.py 2009-02-23 13:37:47 UTC (rev 97164)
+++ z3c.jsonrpc/trunk/src/z3c/jsonrpc/publisher.py 2009-02-23 13:58:39 UTC (rev 97165)
@@ -164,35 +164,11 @@
# 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
@@ -210,7 +186,6 @@
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.
More information about the Checkins
mailing list