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

Philipp von Weitershausen philipp at weitershausen.de
Tue Aug 5 07:41:54 EDT 2008


Chris Withers wrote:
> Nikolay Kim wrote:
>>> I'm aware of this but it kind of defeats the idea of seperating code 
>>> and   configuration...
>>>
>>> So, other ideas?
>>
>> create new zcml directive.
> 
> That seems pretty heavyweight :-/

It's not. It's in fact relatively easy to write a custom utility 
directive that takes arbitrary parameters and then passes them on to the 
utility's factory.

The question is whether that's a good idea. I don't think it is. Either 
the parameters you want to pass have to do with code, then ZCML isn't 
the right *tool* because from ZCML you can only pass Unicode strings 
(for arbitrary parameters, ZCML can't do its magic of resolving dotted 
names or validating or whatever).

Or the parameters you want to pass have to do with configuration (e.g. 
some server name, a port, a directory, etc.). Then ZCML isn't the right 
*place*. An admin-friendy place (zope.conf, paste.ini, custom 
configuration file, etc.) would be a much better place. Or make it a 
local persistent utility that stores its configuration persistently and 
allows it to be changed TTW.


More information about the Zope-Dev mailing list