[Zope-dev] Re: [Zope] Setting SERVER_NAME for ZServer

Bill Anderson bill.anderson@libc.org
Fri, 12 Nov 1999 13:03:36 -0700


Itamar Shtull-Trauring wrote:
> 
> The ZServer SERVER_NAME can be set by editing ZServer/medusa/http_server.py,
> and adding
> 
>         server.server_name = "www.example.com"
> 
> at line 554, right before server_port is set but after the unwanted
> server_name is set, so the new value replaces the unwanted one.
>


Any reason the following code:
----------------------------------------
        if not ip:
            self.log_info('Computing default hostname', 'warning')
            ip = socket.gethostbyname (socket.gethostname())

        try:
            self.server_name = socket.gethostbyaddr (ip)[0]

        except socket.error:
            self.log_info('Cannot do reverse lookup', 'warning')
            self.server_name = ip       # use the IP address as the
"hostname"
----------------------------------------

can't be replaced with:
----------------------------------------
        if not ip:
            self.log_info('Computing default hostname', 'warning')
            ip = socket.gethostbyname (socket.gethostname())
        try:
            self.server_name = os.environ['SERVER_NAME']
        except KeyError:
            self.server_name = socket.gethostbyaddr (ip)[0]
        except socket.error:
            self.log_info('Cannot do reverse lookup', 'warning')
            self.server_name = ip       # use the IP address as the
"hostname"
---------------------------------------

And then the start script (or Zope.pcgi) could then set SERVER_NAME
prior to calling the server proper? 

Just curious ... 
Bill
-- 
"They laughed at Columbus, they laughed at Fulton, they laughed at the
Wright brothers.  But they also laughed at Bozo the Clown." -- Carl
Sagan