anybody have a CGIXMLRPCRequestHandler example?
Chris Curvey
ccurvey at gmail.com
Mon May 2 13:12:38 EDT 2005
here's the simple example, for posterity
import os
import SimpleXMLRPCServer
class Foo:
def settings(self):
return os.environ
def echo(self, something):
return something
def greeting(self, name):
return "hello, " + name
handler = SimpleXMLRPCServer.CGIXMLRPCRequestHandler()
handler.register_instance(Foo())
handler.handle_request()
and here's an example of the client that has to speak with it. My
mistake was trying to call the server thru a web browser. The
"textcall" shows you the format of the incoming request (which I
suppose I could have built by hand by reading the spec).
import xmlrpclib
server = xmlrpclib.ServerProxy("http://127.0.0.1/cms/Foo.py")
yoonikode = u'Sacr\xe9 Bleu'
tup = tuple([yoonikode])
print tup
textcall = xmlrpclib.dumps(tup,("server.echo"))
print textcall
print server.echo("hi")
print server.greeting("dilbert")
print server.greeting(yoonikode)
More information about the Python-list
mailing list