Link to home
Start Free TrialLog in
Avatar of ramrom
ramromFlag for United States of America

asked on

Using XmlHTTP to communicate with python program under apache2triad

I'm so new at this...

I am using XmlHTTP to communicate with a python program under apache2triad. Right now I have the program in a subfolder under htdocs.

import cgi fails

What is the correct way to set up apache2triad so the program will run and can import cgi?

Avatar of ramrom
ramrom
Flag of United States of America image

ASKER

Well I got the first improvement:
my file began with
#!h:/apache2triad/python/bin/python.exe
and that was getting me version 2.3 of python
so I changed it to
#!h:/python25/python.exe
and now I get cgi imported!
Avatar of ramrom

ASKER

So I have moved things along (with much greater understanding). Now I find I don't even need cgi, as I'm looking for the QUERY_STRING and that resides in os.environ!

So now I want to change the question. How can I communicate with a long-running python program. Something along the lines of SimpleXMLRPCServer, using XmlHTTP.
Avatar of RichieHindle
RichieHindle

SimpleXMLRPCServer is a good choice - there's some example server code here: http://docs.python.org/lib/simple-xmlrpc-servers.html along with an example client to go with it.
Avatar of ramrom

ASKER

I've been aware of that module, in fact have played with it. My goal now is to communicate from a browser page which AFAIK requires using the browser's XMLHTTPRequest object. In Mozilla (at least) the URL accepted by XMLHTTPRequest is relative to the one that originally loaded the page, which AFAIK precludes specifying a different port.

Or I need some other magic client that will work form a browser.

I have discovered that mod_python can be "added" to Apache, which creates the environment for the long running Python interpreter. Unfortunately the version of mod_python for my version of apache is only available for Linux, and I'm running windows.

I'm working from within pyjamas (http://trac.pyworks.org/pyjamas) which offers JSON-RPC. A similar versioning problem arose trying to install a JSON-RPC service. There is an article (http://trac.pyworks.org/pyjamas/wiki/DjangoWithPyJamas) regarding JSON-RPC with Django, and I may try that route.
Ah, OK.  I didn't realise you were using XMLHTTPRequest from a browser.  Then my statement "SimpleXMLRPCServer is a good choice" is wrong - XMLHTTPRequest and XMLRPC are very different, and incompatible, things.  Most long-running Python programs that use a browser as a client run under mod_python (Django included, although there are alternatives).  If you're free to choose your web framework, are you not also free to upgrade your Apache?
Avatar of ramrom

ASKER

I regret not being more explicit up front as to what I'm doing. And usually I'm the one who is begging others to be more explicit!

"are you not also free to upgrade your Apache?" Good question. I installed apache by way of the package "apache2triad". I don't know whether it is possible to upgrade tha apache part of that.

I also did with the help of the mod_python email list locate windows binaries. How one would know where to find them is a mystery as there are no links on the web site (that I could find).

So now I have installed mod_python but apache errors on trying to load mod_python.

The Apache service named Apache2Triad Apache2 Service reported the following error:
 >>> httpd.exe: Syntax error on line 1103 of H:/apache2triad/conf/httpd.conf: Cannot load H:/apache2triad/modules/mod_python.so into server: The specified procedure could not be found.
ASKER CERTIFIED SOLUTION
Avatar of mish33
mish33
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ramrom

ASKER

Sorry I did not return here to give the resolution. I had used the wrong mod_python installer. Using the correct one solved the problem.

Even on Windows the modules all have .so extension.
Thanks. It's good to know.