[Zope-Checkins] CVS: Zope3/lib/python/Zope/Server - HTTPServer.py:1.1.2.10
Shane Hathaway
shane@digicool.com
Tue, 27 Nov 2001 12:10:24 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/Server
In directory cvs.zope.org:/tmp/cvs-serv18994/lib/python/Zope/Server
Modified Files:
Tag: Zope-3x-branch
HTTPServer.py
Log Message:
Re-enabled testHTTPServer2, with logging turned off by default.
=== Zope3/lib/python/Zope/Server/HTTPServer.py 1.1.2.9 => 1.1.2.10 ===
if not self.wrote_header:
self.write('')
- channel = self.channel
- channel.server.hit_log.log(self)
+ hit_log = self.channel.server.hit_log
+ if hit_log is not None:
+ hit_log.log(self)
def write(self, data):
channel = self.channel
@@ -620,7 +621,7 @@
SERVER_IDENT = 'Zope.Server.HTTPServer.http_server'
def __init__(self, ip, port, tasks=None, adj=None, start=1,
- hit_log=None):
+ hit_log=None, verbose=0):
# Assumes sock is already bound.
if adj is None:
adj = default_adj
@@ -631,19 +632,22 @@
self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
self.set_reuse_addr()
self.bind((ip, port))
+ self.verbose = verbose
- if hit_log is None:
- hit_log = CommonHitLogger()
+ #if hit_log is None:
+ # hit_log = CommonHitLogger()
self.hit_log = hit_log
host, port = self.socket.getsockname()
if not ip:
- self.log_info('Computing default hostname', 'info')
+ if verbose:
+ self.log_info('Computing default hostname', 'info')
ip = socket.gethostbyname (socket.gethostname())
try:
self.server_name = socket.gethostbyaddr (ip)[0]
except socket.error:
- self.log_info('Cannot do reverse lookup', 'info')
+ if verbose:
+ self.log_info('Cannot do reverse lookup', 'info')
self.server_name = ip # use the IP address as the "hostname"
if start:
@@ -652,11 +656,12 @@
def accept_connections(self):
self.accepting = 1
self.socket.listen(self.adj.backlog) # Circumvent asyncore's NT limit
- self.log_info('HTTP server started.\n'
- '\tHostname: %s\n\tPort: %d' % (
- self.server_name,
- self.port
- ))
+ if self.verbose:
+ self.log_info('HTTP server started.\n'
+ '\tHostname: %s\n\tPort: %d' % (
+ self.server_name,
+ self.port
+ ))
def readable(self):
return (self.accepting and