anybody have a CGIXMLRPCRequestHandler example?

C

ccurvey

I see the ones in the docs, but I really (apparently) need some usage
notes. Something as simple as an "echo" would probably do the trick.
 
C

Chris Curvey

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top