[Zope-Checkins] CVS: Zope/lib/python/Zope/Startup - datatypes.py:1.6.2.6 handlers.py:1.6.2.3 zopeschema.xml:1.7.2.6

Chris McDonough chrism at zope.com
Sun Aug 17 18:10:22 EDT 2003


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

Modified Files:
      Tag: Zope-2_7-branch
	datatypes.py handlers.py zopeschema.xml 
Log Message:
Merge from HEAD:

Import tempstorage from its new location instead of from TemporaryFolder.

Implement new "environment" section in config file which allows the
setting of environment variables within the configuration file.

Implement new "path" section in config file which allows insertions into
the Python module search path within the configuration file.

Fix bug where $INSTANCE/Products was not inserted into the products
path by default.

Note that most of these changes are for more comprehensive Windows service
support.  Windows can't run a batch file as a service, and sometimes it
is necessary to both munge the python module search path and environment
at startup time.  Instead of writing an executable application to do this,
we rely on the configuration machinery.




=== Zope/lib/python/Zope/Startup/datatypes.py 1.6.2.5 => 1.6.2.6 ===
--- Zope/lib/python/Zope/Startup/datatypes.py:1.6.2.5	Sat Aug  2 18:56:47 2003
+++ Zope/lib/python/Zope/Startup/datatypes.py	Sun Aug 17 17:09:46 2003
@@ -126,6 +126,8 @@
     swhome = os.path.dirname(os.path.dirname(here))
     section.softwarehome = swhome
     section.zopehome = os.path.dirname(os.path.dirname(swhome))
+    if section.environment is None:
+        section.environment = {}
     if section.cgi_environment is None:
         section.cgi_environment = {}
     if section.clienthome is None:
@@ -223,7 +225,7 @@
     # and a temporary storage for session data
     from ZODB.Connection import Connection
     from ZODB.config import FileStorage
-    from Products.TemporaryFolder.config import TemporaryStorage
+    from tempstorage.config import TemporaryStorage
 
     l = []
     class dummy:
@@ -248,7 +250,8 @@
     l.append(main)
 
     ts = dummy('temporary storage for sessioning')
-    temporary = ZopeDatabase(dummy('temporary', storage=TemporaryStorage(ts),
+    temporary = ZopeDatabase(dummy('temporary',
+                                   storage=TemporaryStorage(ts),
                                    cache_size=5000, pool_size=7,
                                    version_pool_size=3, version_cache_size=100,
                                    mount_points=['/temp_folder'],


=== Zope/lib/python/Zope/Startup/handlers.py 1.6.2.2 => 1.6.2.3 ===
--- Zope/lib/python/Zope/Startup/handlers.py:1.6.2.2	Mon Jul 28 00:09:02 2003
+++ Zope/lib/python/Zope/Startup/handlers.py	Sun Aug 17 17:09:46 2003
@@ -1,4 +1,5 @@
 import os
+import sys
 
 # top-level key handlers
 
@@ -126,15 +127,33 @@
     fixups of values that require knowledge about configuration
     values outside of their context. """
 
+    # Set environment variables
+    for k,v in config.environment.items():
+        os.environ[k] = v
+
+    # Add directories to the pythonpath; always insert instancehome/lib/python
+    instancelib = os.path.join(config.instancehome, 'lib', 'python')
+    if instancelib not in config.path:
+        config.path.append(instancelib)
+    path = config.path[:]
+    path.reverse()
+    for dir in path:
+        sys.path.insert(0, dir)
+
     # Add any product directories not already in Products.__path__.
-    # Directories are added in the order
-    if config.products:
-        import Products
-        L = []
-        for d in config.products + Products.__path__:
-            if d not in L:
-                L.append(d)
-        Products.__path__[:] = L
+    # Directories are added in the order they are mentioned
+    # Always insert instancehome.Products
+
+    instanceprod = os.path.join(config.instancehome, 'Products')
+    if instanceprod not in config.products:
+        config.products.append(instanceprod)
+    
+    import Products
+    L = []
+    for d in config.products + Products.__path__:
+        if d not in L:
+            L.append(d)
+    Products.__path__[:] = L
 
     # if no servers are defined, create default http server and ftp server
     if not config.servers:


=== Zope/lib/python/Zope/Startup/zopeschema.xml 1.7.2.5 => 1.7.2.6 ===
--- Zope/lib/python/Zope/Startup/zopeschema.xml:1.7.2.5	Sat Aug  2 13:57:33 2003
+++ Zope/lib/python/Zope/Startup/zopeschema.xml	Sun Aug 17 17:09:46 2003
@@ -7,7 +7,7 @@
   <import package="zLOG"/>
   <import package="ZODB"/>
   <import package="ZServer"/>
-  <import package="Products.TemporaryFolder"/>
+  <import package="tempstorage"/>
 
   <sectiontype name="logger" datatype=".LoggerFactory">
     <description>
@@ -34,6 +34,20 @@
     </key>
   </sectiontype>
 
+  <sectiontype name="environment"
+               datatype=".cgi_environment"
+               keytype="identifier">
+    <description>
+     A section which allows you to define simple key-value pairs which
+     will be used as environment variable settings during startup.  
+    </description>
+    <key name="+" attribute="environ">
+      <description>
+        Use any key/value pair, e.g. 'MY_PRODUCT_ENVVAR foo_bar'
+      </description>
+    </key>
+  </sectiontype>
+
   <sectiontype name="zoperunner">
     <description>
       This section describes the options for zopectl.  These options
@@ -184,6 +198,15 @@
 
   <!-- schema begins  -->
 
+  <section type="environment" attribute="environment" name="*">
+    <description>
+     A section which allows a user to define arbitrary key-value pairs for
+     use as environment variables during Zope's run cycle.  It
+     is not recommended to set system-related environment variables such as
+     PYTHONPATH within this section.
+    </description>
+  </section>
+
   <key name="instancehome" datatype="existing-directory"
        required="yes">
     <description>
@@ -207,6 +230,28 @@
     <metadefault>$instancehome/var</metadefault>
   </key>
 
+  <multikey name="products" datatype="existing-directory">
+    <description>
+      This specifies additional product directories which are added to
+      Products.__path__.  Directories are added in the order in which
+      they are specified.
+    </description>
+    <metadefault>$instancehome/Products</metadefault>
+  </multikey>
+
+  <multikey name="path" datatype="existing-directory">
+    <description>
+      This specifies additional paths directories which are inserted into
+      the beginning of Python's module search path.  The set of directories
+      specified is inserted into the beginning of the module search path in
+      the order which they are specified here.  Note that the processing of
+      this directive may happen too late under some circumstances; it is
+      recommended that you use the PYTHONPATH environment variable if
+      using this directive doesn't work for you.
+    </description>
+    <metadefault>$instancehome/lib/python</metadefault>
+  </multikey>
+
   <key name="pid-filename" datatype="existing-dirpath">
     <description>
       The full path to which the Zope process will write its
@@ -324,15 +369,6 @@
       the database has been opened are not visible.
     </description>
   </key>
-
-  <multikey name="products" datatype="existing-directory">
-    <description>
-      This specifies additional product directories which are added to
-      Products.__path__.  Directories are added in the order in which
-      they are specified.
-    </description>
-    <metadefault>$instancehome/Products</metadefault>
-  </multikey>
 
   <key name="structured-text-header-level" datatype="integer" default="3"
        handler="structured_text_header_level">




More information about the Zope-Checkins mailing list