[Zope-Checkins] CVS: Zope3/lib/python/Zope/Server - __init__.py:1.1.2.1

Brian Lloyd brian@digicool.com
Fri, 16 Nov 2001 11:57:38 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/Server
In directory cvs.zope.org:/tmp/cvs-serv16139

Added Files:
      Tag: Zope-3x-branch
	__init__.py 
Log Message:
probably broke it but good. :)


=== Added File Zope3/lib/python/Zope/Server/__init__.py ===
from medusa.test import max_sockets


CONNECTION_LIMIT=max_sockets.max_select_sockets()


# Try to poke zLOG default logging into asyncore
# XXX We should probably should do a better job of this,
#     however that would mean that ZServer required zLOG.
try:
    from zLOG import LOG, register_subsystem, BLATHER, INFO, WARNING, ERROR
    register_subsystem('ZServer')
    severity={'info':INFO, 'warning':WARNING, 'error': ERROR}

    def log_info(self, message, type='info'):
        if message[:14]=='adding channel' or \
           message[:15]=='closing channel' or \
           message == 'Computing default hostname':
            LOG('ZServer', BLATHER, message)
        else:
            LOG('ZServer', severity[type], message)     

    import asyncore
    asyncore.dispatcher.log_info=log_info
except:
    pass

# A routine to try to arrange for request sockets to be closed
# on exec. This makes it easier for folks who spawn long running
# processes from Zope code. Thanks to Dieter Maurer for this.
try:
    import fcntl, FCNTL
    FCNTL.F_SETFD; FCNTL.FD_CLOEXEC
    def requestCloseOnExec(sock):
        try:    fcntl.fcntl(sock.fileno(), FCNTL.F_SETFD, FCNTL.FD_CLOEXEC)
        except: pass

except (ImportError, AttributeError):

    def requestCloseOnExec(sock):
        pass

import asyncore
from medusa import resolver, logger
from HTTPServer import zhttp_server, zhttp_handler
from PubCore import setNumberOfThreads
from medusa.monitor import secure_monitor_server

# override the service name in logger.syslog_logger
logger.syslog_logger.svc_name='ZServer'