[Zope] I'm clumsy with XML-RPC.

Brad Clements bkc at murkworks.com
Fri Dec 26 12:37:18 EST 2003


On 25 Dec 2003 at 9:10, Kyler Laird wrote:

> Trying what would seem to be an elegant way of calling it,
>  Zope_server.test(first='foo', second='bar')
> yields an error.
>  TypeError: __call__() got an unexpected keyword argument 'second'

You can not use keyword arguments with xml-rpc. Only positional arguments are 
allowed.

Also, Zope's mapply() doesn't like passing a variable number of arguments to 
PythonScript objects that try to use *args or **kw.

So, I've always just declared my exposed functions as taking one argument, a 
dictionary.

All xml-rpc clients just pass one dictionary, and that dict serves as keywords.

So your server function could be

params: d={}

and the client could call



>  Zope_server.test({'first': 'foo', 'second': 'bar'})

> That still doesn't give me access to "second".

Back on the server side, you'd use something like this:

first = d.get('first', None)
second = d.get('second', None)


-- 
Brad Clements,                bkc at murkworks.com   (315)268-1000
http://www.murkworks.com                          (315)268-9812 Fax
http://www.wecanstopspam.org/                   AOL-IM: BKClements




More information about the Zope mailing list