The XMLRPC responder implements an application website. XMLRPC is a language-neutral protocol for distributed computing, using XML for serialization and HTTP for transport. The Python standard library includes a well-written XMLRPC library, which forms the basis for this class. By mixing the XMLRPC responder into your class, you can easily make your instance's methods available to clients over the network. Instances inherit one attribute and two methods:
| request) |
| request) |
respond or serve_xmlrpc.
protected.
In a Python shell, create an XMLRPC server like so:
>>> import httpy >>> class Responder(httpy.responders.XMLRPC): ... protected = ['private'] ... def private(self): ... return 'leave me alone!' ... def ping(self): ... return 'pong' ... >>> responder = Responder() >>> coupler = httpy.couplers.StandAlone(responder) >>> coupler.go() httpy.server INFO httpy started on port 8080
Then, in a second shell, you can talk to your server like this:
>>> import xmlrpclib
>>> server = xmlrpclib.ServerProxy('http://localhost:8080/')
>>> server.ping()
'pong'
>>> server.private()
Traceback (most recent call last):
...
xmlrpclib.Fault: <Fault 404: "method 'private' not found">
>>>