[Zconfig] Overlaying multiple config files

Fred Drake fred at zope.com
Mon Apr 26 09:35:01 EDT 2004


On Monday 26 April 2004 08:26 am, Moore, Paul wrote:
 > I have an application suite which currently uses ConfigParser for
 > configuration information. The config is built up in 3 parts, from
 > some hard-coded defaults, then from a suite-specific ini file
 > (suite.ini) and then from a further application-specific ini file
 > (app.ini). I'd like to do something similar with ZConfig, but I'm not
 > clear how to.

This was never a requirement for ZConfig, so we've never implemented anything 
like this.  It's not entirely clear what the right thing to do is in the 
general case.  Given that the schema support is so different from 
ConfigParser, I expect it would be difficult to determine the best way to 
merge two configurations.

 > Defaults are easy - these can be added to the schema. But I can't see
 > how to overlay 2 files. It looks like I probably need to call loadFile
 > on a loader object multiple times, but I'm not sure how.

That currently would provide multiple independent configurations using the 
same schema which really isn't what you're asking for.

You could load two configurations and then merge them in the application, but 
that's tedious and prone to error as the schema evolves.  It also requires 
each layer of the configuration data to be a complete configuration by 
itself.

One bit of functionality that I've thought about a bit lately would be to 
support loading a "raw" configuration, so that nothing is actually converted 
to the internal data types, but the configuration data can be examined 
directly.  I suspect the merging of layers should be done using such a raw 
structure, and then the result should be "cooked" by performing data 
conversions in the normal way.


  -Fred

-- 
Fred L. Drake, Jr.  <fred at zope.com>
PythonLabs at Zope Corporation




More information about the ZConfig mailing list