[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/ port the
product-configuration support from Zope 2
Fred L. Drake, Jr.
fdrake at gmail.com
Tue Oct 31 11:16:42 EST 2006
Log message for revision 71011:
port the product-configuration support from Zope 2
(trunk revisions 39635, 39652)
tests and documentation will come, but committing this now to avoid blocking
others
Changed:
A Zope3/trunk/src/zope/app/appsetup/product.py
U Zope3/trunk/src/zope/app/appsetup/schema.xml
U Zope3/trunk/src/zope/app/server/main.py
U Zope3/trunk/src/zope/app/twisted/main.py
-=-
Added: Zope3/trunk/src/zope/app/appsetup/product.py
===================================================================
--- Zope3/trunk/src/zope/app/appsetup/product.py 2006-10-31 14:54:12 UTC (rev 71010)
+++ Zope3/trunk/src/zope/app/appsetup/product.py 2006-10-31 16:16:41 UTC (rev 71011)
@@ -0,0 +1,28 @@
+"""Access to product-specific configuration.
+
+"""
+__docformat__ = "reStructuredText"
+
+import zope.testing.cleanup
+
+_configs = {}
+
+zope.testing.cleanup.addCleanUp(_configs.clear)
+
+
+def getProductConfiguration(name):
+ """Return the product configuration for product `name`.
+
+ If there is no configuration for `name`, None is returned.
+
+ """
+ return _configs.get(name)
+
+
+def setProductConfigurations(configs):
+ """Initialize product configuration from ZConfig data."""
+ pconfigs = {}
+ for pconfig in configs:
+ pconfigs[pconfig.getSectionName()] = pconfig.mapping
+ _configs.clear()
+ _configs.update(pconfigs)
Property changes on: Zope3/trunk/src/zope/app/appsetup/product.py
___________________________________________________________________
Name: svn:mime-type
+ text/x-python
Name: svn:eol-style
+ native
Modified: Zope3/trunk/src/zope/app/appsetup/schema.xml
===================================================================
--- Zope3/trunk/src/zope/app/appsetup/schema.xml 2006-10-31 14:54:12 UTC (rev 71010)
+++ Zope3/trunk/src/zope/app/appsetup/schema.xml 2006-10-31 16:16:41 UTC (rev 71011)
@@ -13,6 +13,47 @@
<!-- logging configuration -->
<import package="ZConfig.components.logger" />
+ <abstracttype name="zope.product.base">
+ <!-- Poor name inherited from Zope 2.
+ This can't be changed since components refer to this in a
+ similar way as to public base classes. Components that want
+ to work with both Zope 2 and Zope 3 need this to match the
+ existing Zope 2 name.
+ -->
+ <description>
+ Base type for component-specific configuration sections.
+
+ Specific products should implement configuration sections by
+ defining sections types that implement this abstract type and
+ using their own schema component to define meaningful settings.
+
+ </description>
+ </abstracttype>
+
+ <sectiontype name="product-config" implements="zope.product.base">
+ <description>
+ Component-specific configuration, expressed as arbitrary name-value pairs.
+ </description>
+
+ <key name="+"
+ attribute="mapping"
+ required="no"
+ />
+ </sectiontype>
+
+ <multisection type="zope.product.base" name="+"
+ attribute="product_config">
+ <description>
+ Component-specific configuration stanzas.
+
+ Products may use the <product-config> section type, or may supply
+ a component.xml which defines section types with their own schemas.
+
+ All sections for this multisection will be collected together into the
+ 'product_config' attribute of the configuration object.
+ </description>
+ </multisection>
+
<multisection type="ZODB.database" name="*" required="yes"
attribute="databases">
<description>
Modified: Zope3/trunk/src/zope/app/server/main.py
===================================================================
--- Zope3/trunk/src/zope/app/server/main.py 2006-10-31 14:54:12 UTC (rev 71010)
+++ Zope3/trunk/src/zope/app/server/main.py 2006-10-31 16:16:41 UTC (rev 71011)
@@ -26,6 +26,7 @@
import zope.app.appsetup.appsetup
import zope.app.appsetup.interfaces
+import zope.app.appsetup.product
from zope.event import notify
from zope.server.taskthreads import ThreadedTaskDispatcher
@@ -95,6 +96,8 @@
def setup(options):
sys.setcheckinterval(options.check_interval)
+ zope.app.appsetup.product.setProductConfigurations(
+ options.product_config)
options.eventlog()
options.accesslog()
for logger in options.loggers:
Modified: Zope3/trunk/src/zope/app/twisted/main.py
===================================================================
--- Zope3/trunk/src/zope/app/twisted/main.py 2006-10-31 14:54:12 UTC (rev 71010)
+++ Zope3/trunk/src/zope/app/twisted/main.py 2006-10-31 16:16:41 UTC (rev 71011)
@@ -31,6 +31,7 @@
import zope.app.appsetup
import zope.app.appsetup.interfaces
+import zope.app.appsetup.product
from zope.app import wsgi
from zope.app.twisted import log
@@ -121,6 +122,8 @@
def setup(options):
sys.setcheckinterval(options.check_interval)
+ zope.app.appsetup.product.setProductConfigurations(
+ options.product_config)
options.eventlog()
options.accesslog()
for logger in options.loggers:
More information about the Zope3-Checkins
mailing list