[PEAK] Unifying configuration

alexander smishlajev alex at ank-sia.com
Fri Dec 19 13:47:55 EST 2003


Phillip J. Eby wrote, at 19.12.2003 15:19:

> The issue of listeners and certain other types of configuration, is that 
> one needs the multi-object and nested aspects of ZConfig, while 
> retaining the lazy and declarative aspects of .ini files.

> That is, what if we made it possible for an .ini section handler to 
> parse a different format for that section?  As long as that format 
> doesn't have any lines starting with '[' (and ZConfig files don't), it 
> would be *technically* quite feasible.  The idea is that the section 
> would install a configuration rule that, when invoked, would actually do 
> the parsing of the ZConfig part in order to create the object(s) needed 
> for that configuration rule.

sounds very promising.

> What I'm wondering about is whether this would be too brain-boggling of 
> a syntax.  So far, .ini files have a comforting regularity to their 
> format.  So, if you wander through and see something like this in the 
> middle, what would you think?

with all the complexity of current peak.ini file contents, i do not 
think that these syntax variations will be a big problem.

> A slightly less ambitious approach would be to define the ZConfig data 
> inside of a rule, like this:
> 
> [peak.foo.bar]
> baz = ParseZConfig("""
>     %import my.package
>     <SomethingFromMyPackage>
>     SomeSetting spammity spam
>     </SomethingFromMyPackage>
>     """)
> 
> Of course, you couldn't use triple quotes without escaping them, and 
> there might need to be some kind of de-indenting mechanism.  This 
> approach is awkward, discouraging its use even for things that it's 
> appropriate for.

i don't think ZConfig is indent-sensitive, is it?  however, this syntax 
really does not look handy.

> So one more possible approach:
> 
> [Special section of some kind for something blah...]
> 
> foo.bar =
>     %import my.package
>     <SomethingFromMyPackage>
>     SomeSetting spammity spam
>     </SomethingFromMyPackage>
> 
> That is, in certain special sections, you can use ZConfig nested within 
> a setting, without needing any quotes.  (Naturally, such sections would 
> be using *only* ZConfig for settings; pure Python would not be an option 
> in such sections.)

this one is good, also.

but (as far as i understood) the first approach is more flexible, 
allowing different section handlers, not only ZConfig syntax.  so i 
would prefer the first one.

best wishes,
alex.






More information about the PEAK mailing list