[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: ((&lt;Application instance at 866ae30&gt;, &lt;h3&gt;form&lt;/h3&gt;&lt;table&gt;&lt;tr valign=&quot;top&quot; align=&quot;left&quot;&gt;&lt;th&gt;mode&lt;/th&gt;&lt;td&gt;'plusseven'&lt;/td&gt;&lt;/tr&gt;&lt;tr valign=&quot;top&quot; align=&quot;left&quot;&gt;&lt;th&gt;url&lt;/th&gt;&lt;td&gt;'www.kth.se'&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;h3&gt;cookies&lt;/h3&gt;&lt;table&gt;&lt;/table&gt;&lt;h3&gt;other&lt;/h3&gt;&lt;table&gt;&lt;tr valign=&quot;top&quot; align=&quot;left&quot;&gt;&lt;th&gt;AUTHENTICATION_PATH&lt;/th&gt;&lt;td&gt;''&lt;/td&gt;&lt;/tr&gt;&lt;tr valign=&quot;top&quot; align=&quot;left&quot;&gt;&lt;th&gt;URL1&lt;/th&gt;&lt;td&gt;'http://127.0.0.1:9673'&lt;/td&gt;&lt;/tr&gt;&lt;tr valign=&quot;top&quot; align=&quot;left&quot;&gt;&lt;th&gt;PUBLISHED&lt;/th&gt;&lt;td&gt;&amp;lt;ExternalMethod instance at 8668718&amp;gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr valign=&quot;top&quot; align=&quot;left&quot;&gt;&lt;th&gt;mode&lt;/th&gt;&lt;td&gt;'plusseven'&lt;/td!
&gt;&lt;/tr&gt;&lt;tr valign=&quot;top&quot; align=&quot;left&quot;&gt;&lt;th&gt;BASE2&lt;/th&gt;&lt;td&gt;'http://127.0.0.1:9673/p7call'&lt;/td&gt;&lt;/tr&gt;&lt;tr valign=&quot;top&quot; align=&quot;left&quot;&gt;&lt;th&gt;BASE0&lt;/th&gt;&lt;td&gt;'http://127.0.0.1:9673'&lt;/td&gt;&lt;/tr&gt;&lt;tr valign=&quot;top&quot; align=&quot;left&quot;&gt;&lt;th&gt;URL0&lt;/th&gt;&lt;td&gt;'http://127.0.0.1:9673/p7call'&lt;/td&gt;&lt;/tr&gt;&lt;tr valign=&quot;top&quot; align=&quot;left&quot;&gt;&lt;th&gt;SERVER_URL&lt;/th&gt;&lt;td&gt;'http://127.0.0.1:9673'&lt;/td&gt;&lt;/tr&gt;&lt;tr valign=&quot;top&quot; align=&quot;left&quot;&gt;&lt;th&gt;url&lt;/th&gt;&lt;td&gt;'www.kth.se'&lt;/td&gt;&lt;/tr&gt;&lt;tr valign=&quot;top&quot; align=&quot;left&quot;&gt;&lt;th&gt;URL&lt;/th&gt;&lt;td&gt;'http://127.0.0.1:9673/p7call'&lt;/td&gt;&lt;/tr&gt;&lt;tr valign=&quot;top&quot; align=&quot;left&quot;&gt;&lt;th&gt;TraversalRequestNameStack&lt;/th&gt;&lt;td&gt;[]&lt;/td&gt;&lt;/tr&gt;&lt;tr v!
align=&quot;top&quot; align=&quot;left&quot;&gt;&lt;th&gt;AUTHENTICATED_USER&lt;/th&gt;&lt;td&gt;Anonymous User&lt;/td&gt;&lt;/tr&gt;&lt;tr valign=&quot;top&quot; align=&quot;left&quot;&gt;&lt;th&gt;BASE1&lt;/th&gt;&lt;td&gt;'http://127.0.0.1:9673'&lt;/td&gt;&lt;/tr&gt;&lt;tr valign=&quot;top&quot; align=&quot;left&quot;&gt;&lt;th&gt;URL0&lt;/th&gt;&lt;td&gt;http://127.0.0.1:9673/p7call&lt;/td&gt;&lt;/tr&gt;&lt;tr valign=&quot;top&quot; align=&quot;left&quot;&gt;&lt;th&gt;URL1&lt;/th&gt;&lt;td&gt;http://127.0.0.1:9673&lt;/td&gt;&lt;/tr&gt;&lt;tr valign=&quot;top&quot; align=&quot;left&quot;&gt;&lt;th&gt;BASE0&lt;/th&gt;&lt;td&gt;http://127.0.0.1:9673&lt;/td&gt;&lt;/tr&gt;&lt;tr valign=&quot;top&quot; align=&quot;left&quot;&gt;&lt;th&gt;BASE1&lt;/th&gt;&lt;td&gt;http://127.0.0.1:9673&lt;/td&gt;&lt;/tr&gt;&lt;tr valign=&quot;top&quot; align=&quot;left&quot;&gt;&lt;th&gt;BASE2&lt;/th&gt;&lt;td&gt;http://127.0.0.1:9673/p7call&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;h3&gt;environ&lt!
;/h3&gt;&lt;table&gt;&lt;tr valign=&quot;top&quot; align=&quot;left&quot;&gt;&lt;th&gt;HTTP_ACCEPT_ENCODING&lt;/th&gt;&lt;td&gt;gzip,deflate,compress,identity&lt;/td&gt;&lt;/tr&gt;&lt;tr valign=&quot;top&quot; align=&quot;left&quot;&gt;&lt;th&gt;channel.creation_time&lt;/th&gt;&lt;td&gt;995899297&lt;/td&gt;&lt;/tr&gt;&lt;tr valign=&quot;top&quot; align=&quot;left&quot;&gt;&lt;th&gt;QUERY_STRING&lt;/th&gt;&lt;td&gt;url=www.kth.se&amp;amp;mode=plusseven&lt;/td&gt;&lt;/tr&gt;&lt;tr valign=&quot;top&quot; align=&quot;left&quot;&gt;&lt;th&gt;SERVER_PROTOCOL&lt;/th&gt;&lt;td&gt;1.0&lt;/td&gt;&lt;/tr&gt;&lt;tr valign=&quot;top&quot; align=&quot;left&quot;&gt;&lt;th&gt;SERVER_PORT&lt;/th&gt;&lt;td&gt;9673&lt;/td&gt;&lt;/tr&gt;&lt;tr valign=&quot;top&quot; align=&quot;left&quot;&gt;&lt;th&gt;PATH_INFO&lt;/th&gt;&lt;td&gt;/p7call&lt;/td&gt;&lt;/tr&gt;&lt;tr valign=&quot;top&quot; align=&quot;left&quot;&gt;&lt;th&gt;HTTP_HOST&lt;/th&gt;&lt;td&gt;127.0.0.1:9673&lt;/td&gt;&lt;/tr&gt;&lt;tr!
 valign=&quot;top&quot; align=&quot;left&quot;&gt;&lt;th&gt;REQUEST_METHOD&lt;/th&gt;&lt;td&gt;GET&lt;/td&gt;&lt;/tr&gt;&lt;tr valign=&quot;top&quot; align=&quot;left&quot;&gt;&lt;th&gt;PATH_TRANSLATED&lt;/th&gt;&lt;td&gt;/p7call&lt;/td&gt;&lt;/tr&gt;&lt;tr valign=&quot;top&quot; align=&quot;left&quot;&gt;&lt;th&gt;SCRIPT_NAME&lt;/th&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr valign=&quot;top&quot; align=&quot;left&quot;&gt;&lt;th&gt;SERVER_SOFTWARE&lt;/th&gt;&lt;td&gt;Zope/Zope 2.3.2 (source release, python 1.5.2, linux2) ZServer/1.1b1&lt;/td&gt;&lt;/tr&gt;&lt;tr valign=&quot;top&quot; align=&quot;left&quot;&gt;&lt;th&gt;HTTP_ACCEPT_LANGUAGE&lt;/th&gt;&lt;td&gt;en-us&lt;/td&gt;&lt;/tr&gt;&lt;tr valign=&quot;top&quot; align=&quot;left&quot;&gt;&lt;th&gt;REMOTE_ADDR&lt;/th&gt;&lt;td&gt;127.0.0.1&lt;/td&gt;&lt;/tr&gt;&lt;tr valign=&quot;top&quot; align=&quot;left&quot;&gt;&lt;th&gt;SERVER_NAME&lt;/th&gt;&lt;td&gt;matijek&lt;/td&gt;&lt;/tr&gt;&lt;tr valign=&quot;top&quot; align=&q!
uot;left&quot;&gt;&lt;th&gt;GATEWAY_INTERFACE&lt;/th&gt;&lt;td&gt;CGI/1.1&lt;/td&gt;&lt;/tr&gt;&lt;tr valign=&quot;top&quot; align=&quot;left&quot;&gt;&lt;th&gt;HTTP_USER_AGENT&lt;/th&gt;&lt;td&gt;Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.2) Gecko/20010628&lt;/td&gt;&lt;/tr&gt;&lt;tr valign=&quot;top&quot; align=&quot;left&quot;&gt;&lt;th&gt;HTTP_ACCEPT_CHARSET&lt;/th&gt;&lt;td&gt;ISO-8859-1, utf-8;q=0.66, *;q=0.66&lt;/td&gt;&lt;/tr&gt;&lt;tr valign=&quot;top&quot; align=&quot;left&quot;&gt;&lt;th&gt;HTTP_ACCEPT&lt;/th&gt;&lt;td&gt;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&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;), {}, 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