[Zope-Checkins] CVS: Zope/lib/python/ZServer - utils.py:1.3.2.1 FTPServer.py:1.26.8.1 __init__.py:1.29.8.1 INSTALL.txt:NONE ZService.py:NONE
Chris McDonough
chrism@zope.com
Mon, 21 Jul 2003 12:39:06 -0400
Update of /cvs-repository/Zope/lib/python/ZServer
In directory cvs.zope.org:/tmp/cvs-serv17213/lib/python/ZServer
Modified Files:
Tag: Zope-2_7-branch
FTPServer.py __init__.py
Added Files:
Tag: Zope-2_7-branch
utils.py
Removed Files:
Tag: Zope-2_7-branch
INSTALL.txt ZService.py
Log Message:
Merge changes from HEAD since the release of Zope 2.7a1 into the Zope-2_7-branch in preparation for release of Zope 2.7b1.
=== Added File Zope/lib/python/ZServer/utils.py ===
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
""" A set of utility routines used by asyncore initialization """
def getZopeVersion():
import App.version_txt
return App.version_txt.version_txt()
def patchAsyncoreLogger():
# Poke zLOG default logging into asyncore to send
# messages to zLOG instead of medusa logger
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
# 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
def requestCloseOnExec(sock):
try:
fcntl.fcntl(sock.fileno(), fcntl.F_SETFD, fcntl.FD_CLOEXEC)
except: # XXX What was this supposed to catch?
pass
except (ImportError, AttributeError):
def requestCloseOnExec(sock):
pass
def patchSyslogServiceName():
from medusa import logger
# override the service name in logger.syslog_logger
logger.syslog_logger.svc_name='ZServer'
=== Zope/lib/python/ZServer/FTPServer.py 1.26 => 1.26.8.1 ===
--- Zope/lib/python/ZServer/FTPServer.py:1.26 Tue Mar 18 16:15:14 2003
+++ Zope/lib/python/ZServer/FTPServer.py Mon Jul 21 12:37:27 2003
@@ -98,7 +98,7 @@
self.cookies={}
def _join_paths(self,*args):
- path=apply(os.path.join,args)
+ path=os.path.join(*args)
path=os.path.normpath(path)
if os.sep != '/':
path=path.replace(os.sep,'/')
@@ -543,7 +543,7 @@
c=self.callback
self.callback=None
self.args=None
- apply(c,args)
+ c(*args)
class FTPLimiter:
@@ -599,7 +599,7 @@
def __init__(self,module,*args,**kw):
self.shutup=1
- apply(ftp_server.__init__, (self, None) + args, kw)
+ ftp_server.__init__(self, None, *args, **kw)
self.shutup=0
self.module=module
self.log_info('FTP server started at %s\n'
=== Zope/lib/python/ZServer/__init__.py 1.29 => 1.29.8.1 ===
--- Zope/lib/python/ZServer/__init__.py:1.29 Tue Mar 18 16:15:14 2003
+++ Zope/lib/python/ZServer/__init__.py Mon Jul 21 12:37:27 2003
@@ -12,59 +12,25 @@
##############################################################################
import sys
+import utils
-from medusa.test import max_sockets
-CONNECTION_LIMIT=max_sockets.max_select_sockets()
-
-ZSERVER_VERSION='1.1'
-try:
- import App.version_txt
- ZOPE_VERSION=App.version_txt.version_txt()
-except:
- ZOPE_VERSION='experimental'
+#########################################################
+### declarations used by external packages
+# the exit code used to exit a Zope process cleanly
exit_code = 0
-# 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.
-# (Is that really a bad thing?)
-try:
- from zLOG import LOG, register_subsystem, BLATHER, INFO, WARNING, ERROR
-except ImportError:
- pass
-else:
- 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
-
-# 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
-
- def requestCloseOnExec(sock):
- try:
- fcntl.fcntl(sock.fileno(), fcntl.F_SETFD, fcntl.FD_CLOEXEC)
- except: # XXX What was this supposed to catch?
- pass
+# the ZServer version number
+ZSERVER_VERSION='1.1'
-except (ImportError, AttributeError):
+# the maximum number of incoming connections to ZServer
+CONNECTION_LIMIT=1000 # may be reset by max_listen_sockets handler in Zope
- def requestCloseOnExec(sock):
- pass
+# the Zope version string
+ZOPE_VERSION=utils.getZopeVersion()
+# backwards compatibility aliases
+from utils import requestCloseOnExec
import asyncore
from medusa import resolver, logger
from HTTPServer import zhttp_server, zhttp_handler
@@ -74,5 +40,14 @@
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'
+### end declarations
+##########################################################
+
+# we need to patch asyncore's dispatcher class with a new
+# log_info method so we see medusa messages in the zLOG log
+utils.patchAsyncoreLogger()
+
+# we need to patch the 'service name' of the medusa syslog logger
+utils.patchSyslogServiceName()
+
+
=== Removed File Zope/lib/python/ZServer/INSTALL.txt ===
=== Removed File Zope/lib/python/ZServer/ZService.py ===