Let's have a simple xmlrpc server defined as in the following code:
from SimpleXMLRPCServer import SimpleXMLRPCServer
def add(x,y):
return x+y
server = SimpleXMLRPCServer(("localhost", 8000))
server.register_function(add, 'addthem')
server.register_function(add, 'add.numbers')
server.register_function(add, 'sum.two.numbers')
server.serve_forever()
which you can connect to via
import xmlrpclib
dev = xmlrpclib.ServerProxy("http://localhost:8000/RPC2")
With the dev
object, you cann access the (for reasons of simplicity same) function add
in the server, like
print dev.addthem(1,2)
print dev.add.numbers(1,2)
print dev.sum.two.numbers(1,2)
My question: What are the pieces of those calls? What is dev
(I suppose an instance of xmlrpclib.ServerProxy
), what is sum
in dev.sum
(a function? a callable? a class? an instance?). What is two
in dev.sum.two
...
For example, the following syntax
print dev.add
results in an error
xmlrpclib.Fault: <Fault 1: '<type \'exceptions.Exception\'>:method "add.__str__" is not supported'>
Shouldn't that print something always? What is dev.add
and the other pieces?