[Grok-dev] how to read config from zope.conf

Martijn Faassen faassen at startifact.com
Tue Nov 9 17:14:47 EST 2010


Hey,

On 11/07/2010 11:32 AM, Christian Klinger wrote:
> i think the following steps are needed to read a custom configuration
> form zope.conf...
>
> 1) You have to create your config at the end of the etc/zope.conf.ini file:
>
> # Extra configuration lines can be added to zope_conf's extra option.
> Put for
> # instance productconf sections in here.
> ${zope_conf:extra}
>
> <product-config database>
>      dbname oracle
> </product-config>
>
> 2) run bin/buildout
>
> 3) To access theses configuration in your python module you can do the
> following
>
> from zope.app.appsetup.product import getProductConfiguration
> config = getProductConfiguration('database')
> dbname = config.get('dbname', 'default')

This would work well as a howto somewhere, perhaps in our new community 
documentation. :)

Regards,

Martijn




More information about the Grok-dev mailing list