Right way to define methods to SimpleXMLRPCServer?

Diez B. Roggisch deetsNOSPAM at web.de
Thu Sep 2 23:37:02 CEST 2004


> When I call a method on the server with no args _dispatch is called, and
> the server prints this:
> 
>     {'args': ((),), 'kwds': {}}
> 
> Seems to me like it has one nesting level too many in the args tuple.
> Shouldn't it be ()?  Is this a bug or am I misinterpreting something?

Calling a function without any args always yields an empty tuple - like
this:

>>> def foo(*args): print args
>>> foo()
()
>>>


Looking at SimpleXMLRPCServer one sees this:

        params, method = xmlrpclib.loads(data)
        # generate response
        try:
            if dispatch_method is not None:
                response = dispatch_method(method, params)


So the argument list is the second argument, which is probably the empty
tuple- that explains your observations.

Looking into the docs, you see that dispatch is supposed to have this
signature:

def _dispatch(self, method, params):

No * here, as well as keywords. Then things are more clear :)



-- 
Regards,

Diez B. Roggisch



More information about the Python-list mailing list