[Zope-Checkins] CVS: Zope - Makefile.in:1.1.2.4 setup.py:1.3.4.4 z2.py:1.65.24.2

Matt Behrens matt@zigg.com
Wed, 29 May 2002 15:07:30 -0400


Update of /cvs-repository/Zope
In directory cvs.zope.org:/tmp/cvs-serv8202

Modified Files:
      Tag: zigg_unix-install-control-config-branch
	Makefile.in setup.py z2.py 
Log Message:
More progress:

- Only overwrite zope control script if same revision level or newer.
  This will permit people to install older Zope versions someday without
  clobbering new functionality.

- Implement -C (configuration directory) and -o (option override)
  options for z2.py.

- Correctly implement start and stop, and fix up create a bit.

If people want to check this branch out and see what it can do, now is
probably the time.



=== Zope/Makefile.in 1.1.2.3 => 1.1.2.4 ===
 install-control:
 	install -d -m 755 ${DESTDIR}${BINDIR}
-	install -C -m 755 ZopeControl/zope ${DESTDIR}${BINDIR}
+	if test \! -f ${ZOPE} ; then \
+		install -C -m 755 ZopeControl/zope ${DESTDIR}${BINDIR} ; \
+	fi
+	if test `${PYTHON} ZopeControl/zope revision` -ge \
+		`${ZOPE} revision` ; then \
+		install -C -m 755 ZopeControl/zope ${DESTDIR}${BINDIR} ; \
+	fi
 
 register:
 	install -d -m 755 ${DESTDIR}${CONFIG_DIR}


=== Zope/setup.py 1.3.4.3 => 1.3.4.4 === (875/975 lines abridged)
 class install_data(install_data):
     def finalize_options(self):
-	self.set_undefined_options('install',
-				   ('install_purelib', 'install_dir'),
-				   ('root', 'root'),
-				   ('force', 'force'),
-				  )
+        self.set_undefined_options('install',
+                                   ('install_purelib', 'install_dir'),
+                                   ('root', 'root'),
+                                   ('force', 'force'),
+                                  )
 
     def run(self):
-	self.mkpath(self.install_dir)
-	for f in self.data_files:
-	    if type(f) == StringType:
-		# it's a simple file, so copy it
-		f = convert_path(f)
-		gl = glob(f)
-		if len(gl) == 0:
-		    raise DistutilsFileError, \
-			  "can't copy '%s': glob failed" % f
-		for g in gl:
-		    if os.path.isfile(g):
-		    	if self.warn_dir:
-			    self.warn("setup script did not provide a "
-				      "directory for '%s' -- installing "
-				      "right in '%s'" %
-				      (g, self.install_dir))
-			(out, _) = self.copy_file(g, self.install_dir)
-			self.outfiles.append(out)
-	    else:
-	    	# it's a tuple with path to install to and a list of files
-	    	dir = convert_path(f[0])
-	    	if not os.path.isabs(dir):
-		    dir = os.path.join(self.install_dir, dir)
-	    	elif self.root:
-		    dir = change_root(self.root, dir)
-	    	self.mkpath(dir)
-	    	for data in f[1]:
-		    data = convert_path(data)
-		    gl = glob(data)
-		    if len(gl) == 0:
-			raise DistutilsFileError, \
-			      "can't copy '%s': glob failed" % data
-		    for g in gl:
-		    	if os.path.isfile(g):
-		    	    (out, _) = self.copy_file(g, dir)
-		    	    self.outfiles.append(out)

[-=- -=- -=- 875 lines omitted -=- -=- -=-]

     cmdclass={'install_data': install_data}
 )
 
@@ -902,30 +902,30 @@
     author=AUTHOR,
 
     packages=['ZServer', 'ZServer.PubCore', 'ZServer.medusa',
-	      'ZServer.medusa.contrib', 'ZServer.medusa.demo',
-	      'ZServer.medusa.misc', 'ZServer.medusa.script_handler_demo',
-	      'ZServer.medusa.sendfile', 'ZServer.medusa.test',
-	      'ZServer.medusa.thread'],
+              'ZServer.medusa.contrib', 'ZServer.medusa.demo',
+              'ZServer.medusa.misc', 'ZServer.medusa.script_handler_demo',
+              'ZServer.medusa.sendfile', 'ZServer.medusa.test',
+              'ZServer.medusa.thread'],
 
     data_files=[['ZServer', ['ZServer/*.txt']],
-		['ZServer/medusa', ['ZServer/medusa/*.txt',
-				    'ZServer/medusa/*.html']],
-		['ZServer/medusa/dist', ['ZServer/medusa/dist/*']],
-		['ZServer/medusa/docs', ['ZServer/medusa/docs/*']],
-		['ZServer/medusa/notes', ['ZServer/medusa/notes/*']],
-		['ZServer/medusa/script_handler_demo',
-		    ['ZServer/medusa/script_handler_demo/*.mpy']],
-		['ZServer/medusa/sendfile',
-		    ['ZServer/medusa/sendfile/README']],
-		['ZServer/medusa/test', ['ZServer/medusa/test/*.txt']]],
+                ['ZServer/medusa', ['ZServer/medusa/*.txt',
+                                    'ZServer/medusa/*.html']],
+                ['ZServer/medusa/dist', ['ZServer/medusa/dist/*']],
+                ['ZServer/medusa/docs', ['ZServer/medusa/docs/*']],
+                ['ZServer/medusa/notes', ['ZServer/medusa/notes/*']],
+                ['ZServer/medusa/script_handler_demo',
+                    ['ZServer/medusa/script_handler_demo/*.mpy']],
+                ['ZServer/medusa/sendfile',
+                    ['ZServer/medusa/sendfile/README']],
+                ['ZServer/medusa/test', ['ZServer/medusa/test/*.txt']]],
     cmdclass={'install_data': install_data},
 
 # Does not work on all platforms... not like we ever compiled it before
 # anyway
 #
 #    ext_modules=[
-#	Extension(name='ZServer.medusa.sendfile.sendfilemodule',
-#		  sources=['ZServer/medusa/sendfile/sendfilemodule.c'])]
+#       Extension(name='ZServer.medusa.sendfile.sendfilemodule',
+#                 sources=['ZServer/medusa/sendfile/sendfilemodule.c'])]
 
 )
 


=== Zope/z2.py 1.65.24.1 => 1.65.24.2 ===
 #
 # 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
-# 
+#
 ##############################################################################
 """Zope 2 ZServer start-up file
 
@@ -69,9 +69,9 @@
     (e.g. -d ''), then IP addresses will not be logged. If you have
     DNS service on your local machine then you can set this to
     127.0.0.1.  The default is: %(DNS_IP)s.
-    
+
   -u username or uid number
-  
+
     The username to run ZServer as.  You may want to run ZServer as
     a dedicated user.  This only works under Unix, and if ZServer
     is started as root, and is required in that case.
@@ -88,9 +88,9 @@
     to listen on different addresses.
 
     Multiple -P options can be provided to run multiple sets of servers.
-    
+
   -w port
-  
+
     The Web server (HTTP) port.  This defaults to %(HTTP_PORT)s. The
     standard port for HTTP services is 80.  If this is a dash
     (e.g. -w -), then HTTP is disabled.
@@ -102,7 +102,7 @@
     Multiple -w options can be provided to run multiple servers.
 
   -W port
-  
+
     The "WebDAV source" port.  If this is a dash (e.g. -w -), then
     "WebDAV source" is disabled.  The default is disabled.  Note that
     this feature is a workaround for the lack of "source-link" support
@@ -115,7 +115,7 @@
     Multiple -W options can be provided to run multiple servers.
 
   -f port
-  
+
     The FTP port.  If this is a dash (e.g. -f -), then FTP
     is disabled.  The standard port for FTP services is 21.  The
     default is %(FTP_PORT)s.
@@ -139,7 +139,7 @@
     not specified then the FastCGI Server is disabled.
 
   -m port
-  
+
     The secure monitor server port. If this is a dash
     (-m -), then the monitor server is disabled. The monitor server
     allows interactive Python style access to a running ZServer. To
@@ -170,17 +170,17 @@
 
     Path to the ZServer log file. If this is a relative path then the
     log file will be written to the 'var' directory. The default is
-    %(LOG_FILE)s. 
+    %(LOG_FILE)s.
 
   -r
-    
+
     Run ZServer is read-only mode. ZServer won't write anything to disk.
     No log files, no pid files, nothing. This means that you can't do a
     lot of stuff like use PCGI, and zdaemon. ZServer will log hits to
     STDOUT and zLOG will log to STDERR.
 
   -L
-  
+
     Enable locale (internationalization) support. The value passed for
     this option should be the name of the locale to be used (see your
     operating system documentation for locale information specific to
@@ -200,7 +200,7 @@
     web server:
 
       %(program)s -X -w80
-      
+
   -M file
 
     Save detailed logging information to the given file.
@@ -211,18 +211,17 @@
       - The start of response output, and
       - The end of the request.
 
-  -C file
+  -C dir
 
-     Read instance settings from the given configuration file.  All
-     other command-line options, including overrides (-o), take
-     precedence over settings in the configuration file.
+     Specify that configuration files (i.e. instance.conf) can be found
+     in the given directory.  This will clear all servers (like -X) and
+     load all options present in the [ZServer] section of instance.conf
+     in that directory.
 
   -o section.option=value
 
      Override the given configuration option with the given value.
-     Repeat as many times as necessary for each override.  Overrides
-     take precedence over the configuration file and over other
-     command line options.
+     Repeat as many times as necessary for each override.
 
 Environment settings are of the form: NAME=VALUE.
 
@@ -335,35 +334,112 @@
 # Detailed log file
 DETAILED_LOG_FILE=''
 
+# Instance configuration file directory
+CONFIG_FILE_DIR=''
+
 #
 ########################################################################
 
 ########################################################################
 # Handle command-line arguments:
 
-def server_info(old, v, offset=0):
+def server_info(old, vs, offset=0):
     # interpret v as a port or address/port and get new value
-    if v == '-': v=''
-    l=v.find(':')
-    if l >= 0:
-        a=v[:l]
-        v=v[l+1:]
-    else:
-        a=IP_ADDRESS
+    if vs == '-': vs=''
 
-    if not v: return v
-        
-    try: 
-        v=int(v)
-        if v < 0: raise 'Invalid port', v
-        v=v+offset
-    except: raise 'Invalid port', v
+    for v in vs.split(','):
+        l=v.find(':')
+        if l >= 0:
+            a=v[:l]
+            v=v[l+1:]
+        else:
+            a=IP_ADDRESS
 
-    if type(old) is type(0): old=[(a,v)]
-    else: old.append((a,v))
+        if not v: return v
 
-    return old    
-    
+        try:
+            v=int(v)
+            if v < 0: raise 'Invalid port', v
+            v=v+offset
+        except: raise 'Invalid port', v
+
+        if type(old) is type(0): old=[(a,v)]
+        else: old.append((a,v))
+
+    return old
+
+def readInstanceConf(instance_conf_dir):
+    from ConfigParser import ConfigParser
+    instance_conf = ConfigParser()
+    instance_conf.read(os.path.join(instance_conf_dir, 'instance.conf'))
+
+    # If we have a configuration file, flush default servers
+    m = sys.modules[__name__]
+    m.MONITOR_PORT=m.HTTP_PORT=m.FTP_PORT=m.FCGI_PORT=m.ICP_PORT=0
+    m.PCGI_FILE=''
+
+    # Only read ZServer configuration here.
+    if instance_conf.has_section('ZServer'):
+        for option in instance_conf.options('ZServer'):
+            useOption('ZServer.%s' % option,
+                      instance_conf.get('ZServer', option))
+
+    m.instance_conf = instance_conf
+
+CONFIG_OVERRIDES = {}
+
+def useOption(option, value):
+    (section, name) = option.split('.')
+    name = name.lower()
+    m = sys.modules[__name__]
+
+    if section == 'ZServer':
+        if name == 'zdaemon_pidfile':
+            m.Zpid = value
+        elif name == 'threads':
+            try:
+                m.NUMBER_OF_THREADS = int(value)
+            except:
+                raise 'Invalid value for ZServer.threads', value
+        elif name == 'check_interval':
+            try:
+                value = int(value)
+            except:
+                raise 'Invalid value for ZServer.check_interval', value
+            sys.setcheckinterval(string.atoi(value))
+        elif name == 'debug':
+            try:
+                value = int(value)
+            except:
+                raise 'Invalid value for ZServer.debug', value
+            os.environ['Z_DEBUG_MODE'] = str(value)
+            m.DEBUG = value
+        elif name == 'address':
+            m.IP_ADDRESS = value
+        elif name == 'dns_server':
+            m.DNS_IP = value
+        elif name == 'run_as':
+            m.UID = value
+        elif name == 'http':
+            m.HTTP_PORT = server_info(m.HTTP_PORT, value)
+        elif name == 'ftp':
+            m.FTP_PORT = server_info(m.FTP_PORT, value)
+        elif name == 'pcgi':
+            m.PCGI_FILE = value
+        elif name == 'fastcgi':
+            m.FCGI_PORT = value
+        elif name == 'monitor':
+            m.MONITOR_PORT = server_info(m.MONITOR_PORT, value)
+        elif name == 'icp':
+            m.ICP_PORT = server_info(m.ICP_PORT, value)
+        elif name == 'server_log':
+            m.LOG_FILE = value
+        elif name == 'locale':
+            m.LOCALE_ID = value
+        elif name == 'detailed_log':
+            m.DETAILED_LOG_FILE = value
+    else:
+        m.CONFIG_OVERRIDES[option] = value
 
 try:
     if sys.version.split()[0] < '2.1':
@@ -376,14 +452,14 @@
 
     DEBUG=0
     READ_ONLY=0
-    
+
     # Get environment variables
     for a in args:
         if a.find('='):
             a=a.split('=')
             o=a[0]
             v='='.join(a[1:])
-            if o: 
+            if o:
               os.environ[o]=v
               HTTP_ENV[o]=v
         else:
@@ -446,6 +522,10 @@
             if v=='-': v=''
             FCGI_PORT=v
         elif o=='-M': DETAILED_LOG_FILE=v
+        elif o=='-C':
+            readInstanceConf(v)
+        elif o=='-o':
+            useOption(v.split('='))
 
 except SystemExit: sys.exit(0)
 except:
@@ -507,7 +587,7 @@
 if Zpid and not READ_ONLY:
     import zdaemon, App.FindHomes, posix
     sys.ZMANAGED=1
-    
+
     zdaemon.run(sys.argv, os.path.join(CLIENT_HOME, Zpid))
 
 os.chdir(CLIENT_HOME)
@@ -515,7 +595,7 @@
 def _warn_nobody():
     zLOG.LOG("z2", zLOG.INFO, "Running Zope as 'nobody' can compromise " + \
                               "your Zope files; consider using a " + \
-                              "dedicated user account for Zope") 
+                              "dedicated user account for Zope")
 
 try:
     # Import logging support
@@ -607,7 +687,7 @@
             # environment setting is useful when you want to proxy requests
             # from another web server to ZServer, and would like the CGI
             # environment to reflect the CGI environment of the other web
-            # server.    
+            # server.
             zh = zhttp_handler(MODULE, '', HTTP_ENV)
             hs.install_handler(zh)
 
@@ -632,11 +712,11 @@
             # environment setting is useful when you want to proxy requests
             # from another web server to ZServer, and would like the CGI
             # environment to reflect the CGI environment of the other web
-            # server.    
+            # server.
             zh = WebDAVSrcHandler(MODULE, '', HTTP_ENV)
             hs.install_handler(zh)
 
-            # enable document retrieval of the document source on the 
+            # enable document retrieval of the document source on the
             # standard HTTP port
 
             clients = os.environ.get('WEBDAV_SOURCE_PORT_CLIENTS')
@@ -696,7 +776,7 @@
             zLOG.LOG("z2", zLOG.WARNING, 'Monitor server not started'
                      ' because no emergency user exists.')
         if pw:
-            if type(MONITOR_PORT) is type(0): 
+            if type(MONITOR_PORT) is type(0):
                 MONITOR_PORT=((IP_ADDRESS, MONITOR_PORT),)
             for address, port in MONITOR_PORT:
                 monitor=secure_monitor_server(
@@ -762,7 +842,7 @@
                     gid = pwd.getpwuid(UID)[3]
                     UID = pwd.getpwuid(UID)[0]
                 else:
-                    raise KeyError 
+                    raise KeyError
                 if UID == 'nobody':
                     _warn_nobody()
                 try:
@@ -787,7 +867,7 @@
         # umask is silly, blame POSIX.  We have to set it to get its value.
         current_umask = os.umask(0)
         os.umask(current_umask)
-        if current_umask != 077: 
+        if current_umask != 077:
             current_umask = '%03o' % current_umask
             zLOG.LOG("z2", zLOG.INFO, 'Your umask of ' + current_umask + \
                      ' may be too permissive; for the security of your ' + \