[Zope-Checkins] SVN: Zope/trunk/lib/python/ZServer/datatypes.py fixed http://www.zope.org/Collectors/Zope/1507 (Entry #17, 1.) alias http://www.zope.org/Collectors/Zope/1728

Yvo Schubbe y.2005- at wcm-solutions.de
Mon May 9 03:48:44 EDT 2005


Log message for revision 30303:
  fixed http://www.zope.org/Collectors/Zope/1507 (Entry #17, 1.) alias http://www.zope.org/Collectors/Zope/1728
  
  switched back to ip=self.ip, simplified and fixed prepare() code
  now we are down to 1 failing test on Windows

Changed:
  U   Zope/trunk/lib/python/ZServer/datatypes.py

-=-
Modified: Zope/trunk/lib/python/ZServer/datatypes.py
===================================================================
--- Zope/trunk/lib/python/ZServer/datatypes.py	2005-05-09 07:34:40 UTC (rev 30302)
+++ Zope/trunk/lib/python/ZServer/datatypes.py	2005-05-09 07:48:44 UTC (rev 30303)
@@ -16,34 +16,10 @@
 Each server type is represented by a ServerFactory instance.
 """
 
-import os
 import socket
 import ZConfig
 
-_default_host_info = None
 
-def get_default_host_info():
-    global _default_host_info
-    if _default_host_info is None:
-        hostname = socket.gethostname()
-        try:
-            ip = socket.gethostbyname(hostname)
-        except socket.error:
-            hostname = 'localhost'
-            ip = socket.gethostbyname(hostname)
-        try:
-            hostname = socket.gethostbyaddr(ip)[0]
-        except socket.error:
-            hostname = ip
-        ## AJ: We change 'localhost' to '' to force Medusa to use
-        ## any network interface instead of using only 127.0.0.1. This is 
-        ## a not totally clean solution :-/ See also Collector #1507.
-        if os.name == 'posix' and 'localhost' in hostname.lower(): 
-            hostname = ''
-        _default_host_info = hostname, ip
-    return _default_host_info
-
-
 class ServerFactory:
     def __init__(self, address=None):
         self.ip = None
@@ -53,18 +29,11 @@
         else:
             self.host, self.port = address
 
-    def prepare(self, defaulthost=None, dnsresolver=None,
+    def prepare(self, defaulthost='', dnsresolver=None,
                 module=None, env=None, portbase=None):
-        if defaulthost:
-            hostname = defaulthost
-            ip = socket.gethostbyname(hostname)
-        elif defaulthost is '':
-            hostname = ''
-            ip = '127.0.0.1'
-        else:
-            hostname, ip = get_default_host_info()
         if not self.host:
-            self._set_default_host(hostname, ip)
+            ip = socket.gethostbyname(defaulthost)
+            self._set_default_host(defaulthost, ip)
         else:
             self.ip = socket.gethostbyname(self.host)
         self.dnsresolver = dnsresolver
@@ -107,7 +76,7 @@
         handler._force_connection_close = self.force_connection_close
         if self.webdav_source_clients:
             handler.set_webdav_source_clients(self.webdav_source_clients)
-        server = HTTPServer.zhttp_server(ip=self.host, port=self.port,
+        server = HTTPServer.zhttp_server(ip=self.ip, port=self.port,
                                          resolver=self.dnsresolver,
                                          logger_object=access_logger)
         server.install_handler(handler)
@@ -134,7 +103,7 @@
     def create(self):
         from ZServer.AccessLogger import access_logger
         from ZServer.FTPServer import FTPServer
-        return FTPServer(ip=self.host, hostname=self.host, port=self.port,
+        return FTPServer(ip=self.ip, hostname=self.host, port=self.port,
                          module=self.module, resolver=self.dnsresolver,
                          logger_object=access_logger)
 
@@ -147,7 +116,7 @@
     def create(self):
         from ZServer.AccessLogger import access_logger
         from ZServer.PCGIServer import PCGIServer
-        return PCGIServer(ip=self.host, port=self.port,
+        return PCGIServer(ip=self.ip, port=self.port,
                           module=self.module, resolver=self.dnsresolver,
                           pcgi_file=self.path,
                           logger_object=access_logger)
@@ -172,7 +141,7 @@
     def create(self):
         from ZServer.AccessLogger import access_logger
         from ZServer.FCGIServer import FCGIServer
-        return FCGIServer(ip=self.host, port=self.port,
+        return FCGIServer(ip=self.ip, port=self.port,
                           socket_file=self.path,
                           module=self.module, resolver=self.dnsresolver,
                           logger_object=access_logger)



More information about the Zope-Checkins mailing list