[Zope] DNS lookup problem with urllib in external methods
Oivvio Polite
oivvio@polite.se
Mon, 23 Jul 2001 17:07:53 +0200
> Can you post your exact script & details of how its called?
The whole thing is big and hairy, but this is the method where urlopen gets called.
Calling this thing from a test suite is no problem. Calling it from an External method requires m
me to use ipnumbers instead of hostnames.
def feed_url(self):
debug.lazy_write(debugflags.translator, "[feed url: %s]\n" % self.url )
try:
debug.lazy_write(debugflags.translator, "[opening url: %s]\n" % self.url)
assert type(self.url) == types.StringType
fp = urllib.urlopen(self.url) # I this is where the error will occur
debug.lazy_write(debugflags.translator, "[opened url: %s]\n" % self.url)
actualurl = fp.geturl()
if actualurl != self.url:
self.url = actualurl
debug.lazy_write(debugflags.translator, "[redirect: %s]\n" % self.url)
self.feed(fp.read())
self.close()
debug.lazy_write(debugflags.translator, "[feed and closed trans: %s]\n" % self.url)
fp.close()
except:
self.error = "Could not open url %s" % self.url
debug.lazy_write(debugflags.translator, "[process error: %s]\n" % self.url )
raise
___________________________________________________________________
What zope returns
<html><head><title>Zope</title></head><body bgcolor="#FFFFFF">
<table border="0" width="100%">
<tr valign="TOP">
<td width="10%" align="center">
<img src="http://127.0.0.1:9673/p_/ZButton" alt="Zope">
</td>
<td width="90%">
<h2>Zope Error</h2>
<p>Zope has encountered an error while publishing this resource.</p>
<p>
<strong>Error Type: IOError</strong><br>
<strong>Error Value: [Errno socket error] host not found</strong><br> </p>
<hr noshade>
<p>Troubleshooting Suggestions</p>
<ul>
<li>The URL may be incorrect.</li>
<li>The parameters passed to this resource may be incorrect.</li>
<li>A resource that this resource relies on may be encountering an error.</li>
</ul>
<p>For more detailed information about the error, please
refer to the HTML source for this page.
</p>
<p>If the error persists please contact the site maintainer.
Thank you for your patience.
</p>
</td></tr>
</table>
<p><a href="http://www.zope.org/Credits" target="_top"><img src="http://127.0.0.1:9673/p_/ZopeButton" width="115" height="50" border="0" alt="Powered by Zope" /></a></p></body></html>
<!--
Traceback (innermost last):
File /usr/lib/zope/lib/python/ZPublisher/Publish.py, line 223, in publish_module
File /usr/lib/zope/lib/python/ZPublisher/Publish.py, line 187, in publish
File /usr/lib/zope/lib/python/Zope/__init__.py, line 221, in zpublisher_exception_hook
(Object: ApplicationDefaultPermissions)
File /usr/lib/zope/lib/python/ZPublisher/Publish.py, line 171, in publish
File /usr/lib/zope/lib/python/ZPublisher/mapply.py, line 160, in mapply
(Object: p7call)
File /usr/lib/zope/lib/python/ZPublisher/Publish.py, line 112, in call_object
(Object: p7call)
File /usr/lib/zope/lib/python/Products/ExternalMethod/ExternalMethod.py, line 262, in __call__
(Object: p7call)
(Info: ((<Application instance at 866ae30>, <h3>form</h3><table><tr valign="top" align="left"><th>mode</th><td>'plusseven'</td></tr><tr valign="top" align="left"><th>url</th><td>'www.kth.se'</td></tr></table><h3>cookies</h3><table></table><h3>other</h3><table><tr valign="top" align="left"><th>AUTHENTICATION_PATH</th><td>''</td></tr><tr valign="top" align="left"><th>URL1</th><td>'http://127.0.0.1:9673'</td></tr><tr valign="top" align="left"><th>PUBLISHED</th><td>&lt;ExternalMethod instance at 8668718&gt;</td></tr><tr valign="top" align="left"><th>mode</th><td>'plusseven'</td!
></tr><tr valign="top" align="left"><th>BASE2</th><td>'http://127.0.0.1:9673/p7call'</td></tr><tr valign="top" align="left"><th>BASE0</th><td>'http://127.0.0.1:9673'</td></tr><tr valign="top" align="left"><th>URL0</th><td>'http://127.0.0.1:9673/p7call'</td></tr><tr valign="top" align="left"><th>SERVER_URL</th><td>'http://127.0.0.1:9673'</td></tr><tr valign="top" align="left"><th>url</th><td>'www.kth.se'</td></tr><tr valign="top" align="left"><th>URL</th><td>'http://127.0.0.1:9673/p7call'</td></tr><tr valign="top" align="left"><th>TraversalRequestNameStack</th><td>[]</td></tr><tr v!
align="top" align="left"><th>AUTHENTICATED_USER</th><td>Anonymous User</td></tr><tr valign="top" align="left"><th>BASE1</th><td>'http://127.0.0.1:9673'</td></tr><tr valign="top" align="left"><th>URL0</th><td>http://127.0.0.1:9673/p7call</td></tr><tr valign="top" align="left"><th>URL1</th><td>http://127.0.0.1:9673</td></tr><tr valign="top" align="left"><th>BASE0</th><td>http://127.0.0.1:9673</td></tr><tr valign="top" align="left"><th>BASE1</th><td>http://127.0.0.1:9673</td></tr><tr valign="top" align="left"><th>BASE2</th><td>http://127.0.0.1:9673/p7call</td></tr></table><h3>environ<!
;/h3><table><tr valign="top" align="left"><th>HTTP_ACCEPT_ENCODING</th><td>gzip,deflate,compress,identity</td></tr><tr valign="top" align="left"><th>channel.creation_time</th><td>995899297</td></tr><tr valign="top" align="left"><th>QUERY_STRING</th><td>url=www.kth.se&amp;mode=plusseven</td></tr><tr valign="top" align="left"><th>SERVER_PROTOCOL</th><td>1.0</td></tr><tr valign="top" align="left"><th>SERVER_PORT</th><td>9673</td></tr><tr valign="top" align="left"><th>PATH_INFO</th><td>/p7call</td></tr><tr valign="top" align="left"><th>HTTP_HOST</th><td>127.0.0.1:9673</td></tr><tr!
valign="top" align="left"><th>REQUEST_METHOD</th><td>GET</td></tr><tr valign="top" align="left"><th>PATH_TRANSLATED</th><td>/p7call</td></tr><tr valign="top" align="left"><th>SCRIPT_NAME</th><td></td></tr><tr valign="top" align="left"><th>SERVER_SOFTWARE</th><td>Zope/Zope 2.3.2 (source release, python 1.5.2, linux2) ZServer/1.1b1</td></tr><tr valign="top" align="left"><th>HTTP_ACCEPT_LANGUAGE</th><td>en-us</td></tr><tr valign="top" align="left"><th>REMOTE_ADDR</th><td>127.0.0.1</td></tr><tr valign="top" align="left"><th>SERVER_NAME</th><td>matijek</td></tr><tr valign="top" align=&q!
uot;left"><th>GATEWAY_INTERFACE</th><td>CGI/1.1</td></tr><tr valign="top" align="left"><th>HTTP_USER_AGENT</th><td>Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.2) Gecko/20010628</td></tr><tr valign="top" align="left"><th>HTTP_ACCEPT_CHARSET</th><td>ISO-8859-1, utf-8;q=0.66, *;q=0.66</td></tr><tr valign="top" align="left"><th>HTTP_ACCEPT</th><td>text/xml, application/xml, application/xhtml+xml, text/html;q=0.9, image/png, image/jpeg, image/gif;q=0.2, text/plain;q=0.8, text/css, */*;q=0.1</td></tr></table>), {}, None))
File /usr/lib/zope/Extensions/plussevenhandler.py, line 79, in callplusseven
(Object: ApplicationDefaultPermissions)
File /usr/lib/python1.5/site-packages/plusseven/translator.py, line 197, in processurl
File /usr/lib/python1.5/site-packages/plusseven/translator.py, line 147, in feed_url
File /usr/lib/python1.5/urllib.py, line 59, in urlopen
File /usr/lib/python1.5/urllib.py, line 159, in open
File /usr/lib/python1.5/urllib.py, line 259, in open_http
File /usr/lib/python1.5/httplib.py, line 51, in __init__
File /usr/lib/python1.5/httplib.py, line 79, in connect
IOError: (see above)
-->
--
oivvio polite
cell +46 (0)709 30 40 30 / phone +46 (0)8 669 64 18 / fax +46 (0)8 84 00 18
varvsgatan 10A / s-117 29 stockholm / sweden