[Zope-Checkins] CVS: Zope/lib/python/Zope/Startup - __init__.py:1.2.2.5 handlers.py:1.2.2.4 zopeschema.xml:1.2.2.6

Fred L. Drake, Jr. fred@zope.com
Fri, 14 Feb 2003 01:01:17 -0500


Update of /cvs-repository/Zope/lib/python/Zope/Startup
In directory cvs.zope.org:/tmp/cvs-serv13476

Modified Files:
      Tag: new-install-branch
	__init__.py handlers.py zopeschema.xml 
Log Message:
Lots of changes, ranging from spelling changes to fixes for a real infinite
loop!  This is much closer to actually working now.


=== Zope/lib/python/Zope/Startup/__init__.py 1.2.2.4 => 1.2.2.5 ===
--- Zope/lib/python/Zope/Startup/__init__.py:1.2.2.4	Tue Feb 11 15:16:23 2003
+++ Zope/lib/python/Zope/Startup/__init__.py	Fri Feb 14 01:01:14 2003
@@ -37,18 +37,7 @@
     handlers.handleConfig(_configuration, handler, options)
     return _configuration
 
-def start_zope(config_location, options):
-    check_python_version()
-    cfg = configure(config_location, options)
-
-    if cfg.zope_home not in sys.path:
-        sys.path.insert(0, cfg.zope_home)
-
-    if cfg.software_home not in sys.path:
-        sys.path.insert(0, cfg.software_home)
-
-    sys.path = filter(None, sys.path) # strip empties out of sys.path
-
+def start_zope(cfg):
     # set up our initial logging environment (log everything to stderr
     # if we're not in debug mode).
     import zLOG
@@ -81,23 +70,14 @@
     event_logger.addHandler(startup_handler)
 
     # set a locale if one has been specified in the config
-    cfg.locale and do_locale(cfg.locale)
-
-    # make sure to import zdaemon before zserver or weird things
-    # begin to happen
-    import zdaemon
-
-    # Import ZServer before we open the database or get at interesting
-    # application code so that ZServer's asyncore gets to be the
-    # official one. Also gets SOFTWARE_HOME, INSTANCE_HOME, and CLIENT_HOME
-    import ZServer
+    if cfg.locale:
+        do_locale(cfg.locale)
 
     # Increase the number of threads
-    from ZServer import setNumberOfThreads
-    setNumberOfThreads(cfg.zserver_threads)
+    import ZServer
+    ZServer.setNumberOfThreads(cfg.zserver_threads)
 
-    # if we're not using ZDaemon or if we're the child of a Zdaemon process,
-    # start ZServer servers before we setuid so we can bind to low ports
+    # Start ZServer servers before we setuid so we can bind to low ports:
     socket_err = (
         'There was a problem starting a server of type "%s". '
         'This may mean that your user does not have permission to '
@@ -153,20 +133,18 @@
                 logger = factory() # activate the logger
 
         # flush buffered startup messages to event logger
+        event_logger.removeHandler(startup_handler)
         if cfg.eventlog:
             logger = cfg.eventlog()
             startup_handler.flushBufferTo(logger)
 
-        event_logger.removeHandler(startup_handler)
-
     zLOG.LOG('Zope', zLOG.INFO, 'Ready to handle requests')
 
     # Start Medusa, Ye Hass!
-    sys.ZServerExitCode=0
     try:
         import Lifetime
         Lifetime.loop()
-        sys.exit(sys.ZServerExitCode)
+        sys.exit(ZServer.exit_code)
     finally:
         if not cfg.zserver_read_only_mode:
             try:
@@ -265,15 +243,6 @@
                 'your Zope data, it is recommended you use 077' % current_umask
                 ))
 
-    # try to use a management daemon process.  We do this after we setuid so
-    # we don't write our pidfile out as root.
-    if cfg.use_daemon_process and not cfg.zserver_read_only_mode:
-        import App.FindHomes
-        sys.ZMANAGED=1
-        # zdaemon.run creates a process which "manages" the actual Zope
-        # process (restarts it if it dies).  The management process passes
-        # along signals that it receives to its child.
-        zdaemon.run(sys.argv, cfg.pid_filename)
 
 def do_locale(locale_id):
     # workaround to allow unicode encoding conversions in DTML


=== Zope/lib/python/Zope/Startup/handlers.py 1.2.2.3 => 1.2.2.4 ===
--- Zope/lib/python/Zope/Startup/handlers.py:1.2.2.3	Tue Feb 11 15:09:27 2003
+++ Zope/lib/python/Zope/Startup/handlers.py	Fri Feb 14 01:01:14 2003
@@ -134,12 +134,14 @@
         fixups of values that require knowledge about configuration
         values outside of their context. """
 
-        # set up cgi overrides
-        env = {}
-        for pair in config.cgi_environment_variables:
-            key, value = pair
-            self._env[key] = value
-        config.cgi_environment_variables = env
+        # set up defaults for zopehome and clienthome if they're
+        # not in the config
+        if config.zopehome is None:
+            config.zopehome = zope_home(
+                os.path.dirname(os.path.dirname(config.softwarehome)))
+        if config.clienthome is None:
+            config.clienthome = client_home(
+                os.path.join(config.instancehome, 'var'))
 
         # if no servers are defined, create default http server and ftp server
         if not config.servers:
@@ -158,47 +160,23 @@
             self.prepare_server(section, config)
 
 
-        # set up defaults for zope_home and client_home if they're
-        # not in the config
-        if config.zope_home is None:
-            config.zope_home   = zope_home(
-                os.path.dirname(os.path.dirname(config.software_home))
-                )
-        if config.client_home is None:
-            config.client_home = client_home(
-                os.path.join(config.instance_home, 'var')
-                )
-
         # set up defaults for pid_filename and lock_filename if they're
         # not in the config
         if config.pid_filename is None:
-            config.pid_filename = os.path.join(config.client_home, 'Z2.pid')
+            config.pid_filename = os.path.join(config.clienthome, 'Z2.pid')
         if config.lock_filename is None:
-            config.lock_filename = os.path.join(config.client_home, 'Z2.lock')
+            config.lock_filename = os.path.join(config.clienthome, 'Z2.lock')
 
         # set up a default root filestorage if there are no root storages
         # mentioned in the config
         databases = config.databases
-        root_mounts = [ ('/' in db.mount_points) for db in databases ]
-        if not True in root_mounts:
-            from datatypes import DBWrapper, Factory
-            storagefactory = Factory(
-                'ZODB.FileStorage.FileStorage', None,
-                os.path.join(config.client_home, 'Data.fs'))
-            dbfactory = Factory('ZODB.DB', None)
-            databases.append((['/'], DBWrapper(dbfactory, storagefactory)))
-
-        # do command-line overrides
-        import cmdline
-        opt_processor = cmdline.CommandLineOptions()
-        opt_processor(config, self.options)
 
     _resolver = None
 
     def get_dns_resolver(self, config):
-        if self._resolver is None and self._config.dns_ip_address:
+        if self._resolver is None and config.dns_ip_address:
             from ZServer.medusa import resolver
-            r = resolver.caching_resolver(self._config.dns_ip_address)
+            r = resolver.caching_resolver(config.dns_ip_address)
             self._resolver = r
         return self._resolver
 
@@ -206,8 +184,9 @@
         import ZServer.AccessLogger
         logger = ZServer.AccessLogger.access_logger
         dnsresolver = self.get_dns_resolver(config)
-        # XXX need to get IP_ADDRESS
-        factory.prepare(IP_ADDRESS, resolver, logger, "Zope", env)
+        factory.prepare(config.ip_address or '',
+                        dnsresolver, logger, "Zope",
+                        config.cgi_environment or {})
 
 
 class DummyServerConfig:


=== Zope/lib/python/Zope/Startup/zopeschema.xml 1.2.2.5 => 1.2.2.6 ===
--- Zope/lib/python/Zope/Startup/zopeschema.xml:1.2.2.5	Tue Feb 11 16:18:19 2003
+++ Zope/lib/python/Zope/Startup/zopeschema.xml	Fri Feb 14 01:01:14 2003
@@ -17,21 +17,26 @@
                   required="yes"/>
   </sectiontype>
 
+  <sectiontype name="cgi-environment"
+               datatype=".cgi_environment"
+               keytype="identifier">
+    <key name="+" attribute="environ"/>
+  </sectiontype>
 
   <!-- end of type definitions -->
 
   <!-- schema begins  -->
 
-  <key name="instance-home" datatype="existing-directory"
+  <key name="instancehome" datatype="existing-directory"
        required="yes" handler="instance_home"/>
 
-  <key name="software-home" datatype="existing-directory"
+  <key name="softwarehome" datatype="existing-directory"
        required="yes" handler="software_home"/>
 
-  <key name="zope-home" datatype="existing-directory"
+  <key name="zopehome" datatype="existing-directory"
        handler="zope_home"/>
 
-  <key name="client-home" datatype="existing-directory"
+  <key name="clienthome" datatype="existing-directory"
        handler="client_home"/>
 
   <key name="pid-filename" datatype="existing-dirpath"/>
@@ -61,7 +66,15 @@
   </key>
 
   <key name="zserver-read-only-mode" datatype="boolean" default="off"
-       handler="zserver_read_only_mode"/>
+       handler="zserver_read_only_mode">
+    <description>
+      If this variable is set, then the database is opened in read
+      only mode.  If this variable is set to a string parsable by
+      DateTime.DateTime, then the database is opened read-only as of
+      the time given.  Note that changes made by another process after
+      the database has been opened are not visible.
+    </description>
+  </key>
 
   <key name="structured-text-header-level" datatype="integer" default="3"
        handler="structured_text_header_level"/>
@@ -71,8 +84,7 @@
 
   <key name="publisher-profile-file" handler="publisher_profile_file"/>
 
-  <multikey name="cgi-environment-variable" datatype="key-value"
-            attribute="cgi_environment_variables"/>
+  <section type="cgi-environment" attribute="cgi_environment" name="*"/>
 
   <key name="dns-ip-address" datatype="ipaddr-or-hostname"/>