XML-RPC

Alex Martelli aleaxit at yahoo.com
Sat Nov 1 10:57:27 CET 2003


Ben wrote:
   ...
>     def _dispatch(self, method, params):
>         if method == 'pow':
>             return apply(pow, params)
>         elif method == 'add':
>             return params[0] + params[1]
>         else:
>             raise 'bad method'
   ...
> p= [2,2]
> print myserver._dispatch("add",p)

the way you've coded your server, the client should call myserver.add(2,2)
and NOT what you've coded on the client side.

To see why add a simple print of method and params as the first line
of _dispatch and you'll see:

for the call to .add(2,2):
dispatching 'add' (2, 2)

for the call to ._dispatch('add', [2,2]):
dispatching '_dispatch' ('add', [2, 2])

i.e. the way you call it string '_dispatch' becomes the method and the tuple
of args that ends in params isn't what you apparently think it should be.


Alex





More information about the Python-list mailing list