Remote Objects via CGI?
kpd
kevin.dahlhausen at gmail.com
Wed Nov 1 16:21:58 EST 2006
Thanks Fredrik. I gave XmlRpc a shot as you implied earlier.
It works like a charm. This is how I tested quickly locally without a
large web-server installed:
1. Run cgiserver.py - this takes the place of the normal web server.
2. Then run test.py to make a local xmlrpc call.
./cgi-bin/xmlrpcserver.py:
from SimpleXMLRPCServer import CGIXMLRPCRequestHandler
def test( theList ):
return len(theList)
server = CGIXMLRPCRequestHandler()
server.register_function(test)
server.handle_request()
./test.py:
from xmlrpclib import ServerProxy, Error
server = ServerProxy("http://localhost:8080/cgi-bin/xmlrpcserver.py")
theList = [ 1.1, 2.2, 3.3, 4.4 ]
print server.test( theList )
./cgiserver.py:
from BaseHTTPServer import HTTPServer
from CGIHTTPServer import CGIHTTPRequestHandler
serv = HTTPServer(("", 8080), CGIHTTPRequestHandler)
serv.serve_forever()
The code comes from a the python docs and an old list message at
http://mail.python.org/pipermail/tutor/2001-January/003142.html
More information about the Python-list
mailing list