how do I get configuration from buildout in my plone products?

How do I include configuration information from Buildout in my Plone products?

One of the plone products i'm working on reads and writes info to and from the filesystem. It currently does that inside the egg namespace (for example inside plone/product/directory), but that doesn't look quite right to me.

The idea is to configure a place to store that information in a configurable path, just like iw.fss and iw.recipe.fss does.

For example, save that info to ${buildout:directory}/var/mydata.


You could add configuration sections to your zope.conf file via the zope-conf-additional section of the plone.recipe.zope2instance part:

recipe = plone.recipe.zope2instance
zope-conf-additional =
<product-config foobar>
spam eggs

Any named product-config section is then available as a simple dictionary to any python product that cares to look for it; the above example creates a 'foobar' entry which is a dict with a 'spam': 'eggs' mapping. Here is how you then access that from your code:

from App.config import getConfiguration
config = getConfiguration()
configuration = config.product_config.get('foobar', dict())
spamvalue = configuration.get('spam')

Category:plone Time:2011-05-26 Views:3

Related post

Copyright (C), All Rights Reserved.

processed in 0.431 (s). 13 q(s)