Using CGI to interface with an XML-RPC server

R

Rob Cowie

Hi all,

Assume I have a working XML-RPC server that runs persistently and
correctly accepts remote calls, executes the relevant code and outputs
the XML-RPC result. This is fine when using an XML-RPC client.

However, I wish to provide a web user interface. I gather it is
possible to use PHP as an XML-RPC client but I am unable to do so
because of artificially imposed server constraints. All I am able to
use is good the old CGI.

Is it possible to create python CGI scripts that accept form data in
the usual way, package them as an XML-RPC request, call the server,
receive the response then format this response into valid HTML to be
emitted to the client? Is this desirable (what I mean is... is there an
easier way?).

Is there a better way to use a web browser as what is essentially an
XML-RPC client?

FYI, I know that is seems like using XML-RPC in this case is
pointless.. it isn't, some users do indeed use the server as intended.

Cheers,
 
F

Fredrik Lundh

Rob said:
Is it possible to create python CGI scripts that accept form data in
the usual way, package them as an XML-RPC request, call the server,
receive the response then format this response into valid HTML to be
emitted to the client?

Python ships with cgi and xmlrpc support (cgi and xmlrpclib, respectively),
so I'm not sure why you even think you have to ask...

1. use cgi to parse form data
2. use xmlrpclib to issue request
3. use print or your favourite html templating library to generate
output

(it might be a good idea to check with your web server admins, though,
to make sure they don't have a problem with outgoing HTTP requests)

</F>
 
R

Rob Cowie

Python ships with cgi and xmlrpc support (cgi and xmlrpclib, respectively),
so I'm not sure why you even think you have to ask...
1. use cgi to parse form data
2. use xmlrpclib to issue request
3. use print or your favourite html templating library to generate
output

(it might be a good idea to check with your web server admins, though,
to make sure they don't have a problem with outgoing HTTP requests)

So it is possible.

I'm aware of cgi and xmlrpc modules. The reason I have asked is that
there appears to be much difficulty when tying these two things
together. I also wanted to see if anyone mentioned CGIXMLRPCserver
which is part of the stdlib. I am unsure if this is what I am looking
for. I have been unable to fully comprehend the documentation.

Thanks for your help.
 
B

boxy440

Rob, your python cgi script is just like any other script -- simply
import the xmlrpc lib and use it. The client accessing your cgi
script will have to wait while your script goes off acting as an
xml-rpc client doing whatever business it has to do.
 

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

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top