Re: urlopen works outside Zope, not inside
Dieter Maurer <dieter@handshake.de> wrote:
Bill Bell writes:
I have an External Method containing a reference to urlopen. The procedure that the Method represents works well when invoked from outside of Zope. However, within Zope I get the 10061 socket error, "Connection refused."
Help or advice, please. Are you sure, it gets the same parameters?
"Connection refused" usually means, there is not server at the other end...
I am reasonably confident that this is true. The following code runs successfully inside SciTE. def getCount ( ): from urllib import urlopen, quote from string import find searchFor = 'Cobol' arg = r'http://jobsearch.monster.ca/jobsearch.asp?brd=1&cy=CA&lid=236&fn=6&fn=546&fn...' % ( quote ( searchFor), ) result = arg try: page = urlopen ( arg ) result += '<br/>%s: ' % searchFor for line in page.readlines(): loc = find ( line, "Jobs 1 to " ) if loc != -1: loc2 = find ( line, " of " ) loc3 = find ( line, "</B>", loc2 ) result += line [ loc2 + 4 : loc3 ] return result result += 'None found' except Exception, msg: result += '<br/>' + str ( msg ) return result if __name__ == "__main__": print getCount ( ) If I upload this into an External Method with function name "getCount" and then click on the 'Test' tab I get the following: http://jobsearch.monster.ca/jobsearch.asp?brd=1&cy=CA&lid=236&fn=6&fn=546&fn=660&fn=554&fn=561&q=Cobol<br/>[Errno socket error] (10061, 'Connection refused') Would appreciate any more thoughts you might have. Bill ------------ "It is the time that you have wasted for your rose that makes your rose so important."--St-Exupery
Bill Bell writes:
... "urlopen" working outside but not inside Zope ... ... If I upload this into an External Method with function name "getCount" and then click on the 'Test' tab I get the following:
http://jobsearch.monster.ca/jobsearch.asp?brd=1&cy=CA&lid=236&fn=6&f n=546&fn=660&fn=554&fn=561&q=Cobol<br/>[Errno socket error] (10061, 'Connection refused')
Would appreciate any more thoughts you might have. I once had similar unexplainable problems. An "http_proxy" environment variable finally turned out to be the culprit.
If not, I would look at the complete traceback for your exception. The error message is completely clear: "Connection refused". "urlopen" tries to connect to a host/port where there is no server. With the traceback, I would locate the precise code line and instrument it to find out where "urlopen" tries to connect to. Dieter
participants (2)
-
Bill Bell -
Dieter Maurer