[Zope-dev] Re: configuring global utilities in zcml

Philipp von Weitershausen philipp at weitershausen.de
Tue Aug 5 07:36:05 EDT 2008


Chris Withers wrote:
> Nikolay Kim wrote:
>> you can create utility in python file and then use component=""
>>
>> for example utility.py:
>>
>> class Utility(object):
>>   pass
>>
>> myUtility = Utility()
>>
>>
>> configure.zcml:
>>
>> <utility name="myUtility" component=".utility.myUtility" />
> 
> I'm aware of this but it kind of defeats the idea of seperating code and 
>  configuration...

What kind of configuration are we talking about here? I personally think 
that ZCML is great for switching on and off software components and then 
perhaps configuring a few software-related aspects about them (e.g. 
security protections). But IMHO ZCML is the wrong tool to configure, 
say, database connections or SMTP server settings for outgoing email. 
Because this isn't configuring software, it's configuring settings *for* 
software.

I personally therefore prefer to make settings like those configurable

a) either in zope.conf (there's an easy way to have to custom settings 
in zope.conf read by your utilities, see zope.app.appsetup.product

b) or TTW by implementing the utility in question as a local utility and 
then writing browser pages for it.

I'm all for separating code and configuration, but I'm also all for 
separating admin configuration from developer configuration. I don't 
think an admin should ever have to edit ZCML (and yes, I do realize that 
this wasn't the initial vision, but let's face it, ZCML is a developer 
tool).

Or, if I take Grok: the developer writes Python, the admin writes some 
other form of configuration, be it zope.conf, paste.ini or TTW 
configuration in a browser.


More information about the Zope-Dev mailing list