[Zope-Checkins] SVN: Zope/trunk/ Added a 'product-config' section type to zope.conf, allowing arbitrary key-value mappings.

Tres Seaver tseaver at palladion.com
Wed Oct 26 12:09:59 EDT 2005


Log message for revision 39635:
  Added a 'product-config' section type to zope.conf, allowing arbitrary key-value mappings.
  
  Products can look for such confgiurations to set product-specific options
  (see the example '<product-config>' section in skel/etc/zope.conf.in
  for sample usage).
  
  

Changed:
  U   Zope/trunk/doc/CHANGES.txt
  U   Zope/trunk/lib/python/Zope2/Startup/datatypes.py
  U   Zope/trunk/lib/python/Zope2/Startup/zopeschema.xml
  U   Zope/trunk/skel/etc/zope.conf.in

-=-
Modified: Zope/trunk/doc/CHANGES.txt
===================================================================
--- Zope/trunk/doc/CHANGES.txt	2005-10-26 14:54:24 UTC (rev 39634)
+++ Zope/trunk/doc/CHANGES.txt	2005-10-26 16:09:59 UTC (rev 39635)
@@ -26,6 +26,12 @@
 
     Features added
 
+      - Added a 'product-config' section type to zope.conf, allowing
+        arbitrary key-value mappings.  Products can look for such
+        confgiurations to set product-specific options (see the
+        example '<product-config>' section in skel/etc/zope.conf.in
+        for sample usage).
+
       - Collector #1490: Added a new zope.conf option to control the
         character set used to encode unicode data that reaches
         ZPublisher without any specified encoding.

Modified: Zope/trunk/lib/python/Zope2/Startup/datatypes.py
===================================================================
--- Zope/trunk/lib/python/Zope2/Startup/datatypes.py	2005-10-26 14:54:24 UTC (rev 39634)
+++ Zope/trunk/lib/python/Zope2/Startup/datatypes.py	2005-10-26 16:09:59 UTC (rev 39635)
@@ -150,6 +150,12 @@
     from DBTab.DBTab import DBTab
     section.dbtab = DBTab(mount_factories, mount_points)
 
+    pconfigs = {}
+    for pconfig in section.product_config:
+        pconfigs[pconfig.getSectionName()] = pconfig.mapping
+
+    section.product_config = pconfigs
+
     return section
 
 class ZopeDatabase(ZODBDatabase):
@@ -221,3 +227,6 @@
     Converters.default_encoding = value
     HTTPRequest.default_encoding = value
     HTTPResponse.default_encoding = value
+
+class ProductConfig(dict):
+    pass

Modified: Zope/trunk/lib/python/Zope2/Startup/zopeschema.xml
===================================================================
--- Zope/trunk/lib/python/Zope2/Startup/zopeschema.xml	2005-10-26 14:54:24 UTC (rev 39634)
+++ Zope/trunk/lib/python/Zope2/Startup/zopeschema.xml	2005-10-26 16:09:59 UTC (rev 39635)
@@ -821,5 +821,23 @@
      <metadefault>iso-8859-15</metadefault>
   </key>
 
+  <sectiontype name="product-config">
+    <description>
+    Product-specific configuration, expressed as arbitrary name-value pairs.
+    </description>
 
+    <key name="+"
+         attribute="mapping"
+         required="no"
+         />
+  </sectiontype>
+
+  <multisection type="product-config" name="+"
+                attribute="product_config">
+   <description>
+    Product-specific configuration, expressed as arbitrary name-value pairs.
+   </description>
+  </multisection>
+
+
 </schema>

Modified: Zope/trunk/skel/etc/zope.conf.in
===================================================================
--- Zope/trunk/skel/etc/zope.conf.in	2005-10-26 14:54:24 UTC (rev 39634)
+++ Zope/trunk/skel/etc/zope.conf.in	2005-10-26 16:09:59 UTC (rev 39635)
@@ -969,3 +969,22 @@
 #     #client zeo1
 #   </zeoclient>
 # </zodb_db>
+
+# Product configuration (product-config) section(s)
+#
+# Description:
+#    Add-on products may need to allow the user to specify policy /
+#    configuration.  Such policies may be expressed as a set of
+#    name-value pairs, grouped into a named section (there may
+#    be many such sections, typically one per product).
+#    These sections will be captured in an attribute, 'product_config'
+#    of the top-level config object, under the key corresponding to
+#    the section name.  E.g., the sample section below would be
+#    parsed into a dict, {'bar': 'baz'}, available as
+#    config.product_config['foo']
+#
+# Example: 
+#
+# <product-config foo>
+#    bar baz
+# </product-config>



More information about the Zope-Checkins mailing list