[email protected]
Hello Python User,
I am using python in an openlayers application to access another
server on my network via javascript. The proxy script works fine
when the application runs in Apache HTTP Server, but I get a
"" error after moving
the application to Tomcat. The tomcat cgi configuration tested
fine with a "hello world" python script. I then boiled my proxy
script down to the following:
#!c:/Program Files/Python25/python.exe -u
import urllib2
import cgi
fs = cgi.FieldStorage()
url = fs.getvalue('url', "http://www.openlayers.org";)
try:
y = urllib2.urlopen(url)
print y.read()
except Exception, E:
print "Status: 500 Unexpected Error"
print "Content-Type: text/plain"
print
print "url: ", url
print
print "Some unexpected error occurred. Error text was:", E
This script produces the "". The openlayers homepage is expected. My environment
is Tomcat 6, Apache 2, Win XP, and Python 2.5. I have my local
firewall turned off. Proxy support is enabled, and working, in
Apache 2.0 (I get the error with Apache Server stopped). I seem to
be missing something to facilitate the communication between
python, my network and tomcat. Any direction or solution is
greatly appreciated.
Thank you,
Josh
--
http://mail.python.org/mailman/listinfo/python-list
Re:
Thank you for the response. I have been using
urllib2.urlopen("http://www.openlayers.org";), so I can rule out the
url being incorrect. Since my original question I can add the
following:
1. I am not using a proxy to connect to the internet
2. I added these lines to the script:
...
proxy_support = urllib2.ProxyHandler({})
opener = urllib2.build_opener(proxy_support)
urllib2.install_opener(opener)
...
I believe this tells python not to look for a proxy server.
3. I have added http://www.openlayers.org and its ip to my windows
hosts file
4. socket.gethostbyname produces the same 11001 error as
urllib2.urlopen
You are spot-on suggesting a dns issue. It seems like python
cannot resolve hostnames when it is running in Tomcat 6. Here is
my Tomcat cgi config from web.xml:
cgi
org.apache.catalina.servlets.CGIServlet
debug
0
cgiPathPrefix
WEB-INF/cgi
executable
C:/Program
Files/Python25/python.exe
passShellEnviroment
true
5
cgi
/cgi-bin/*
The hostnames consistently resolve in Apache Server with the same
script, so I don't think my dns config is wrong. I don't have a
local firewall, but could my network firewall be blocking python
from takin care of business? Can anyone share their experience or
a link on running python in Tomcat?
thanks again,
josh
On Fri, 11 Sep 2009 08:54:20 -0500 Chris Withers
wrote:
>[email protected] wrote:
>> fs = cgi.FieldStorage()
>> url = fs.getvalue('url', "http://www.openlayers.org";)
>> try:
>
>insert a "print url" here...
>
>> y = urllib2.urlopen(url)
>> print y.read()
>
>> This script produces the "> failed')>".
>
>This is a name lookup failing, whatever you're ending up with in
>url is
>either incorrect or the dns config of the server it's pointing at
>is
>incorrect...
>
>Chris
>
>--
>Simplistix - Content Management, Batch Processing & Python
>Consulting
>- http://www.simplistix.co.uk
--
http://mail.python.org/mailman/listinfo/python-list
