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

2008-08-05 Thread Philipp von Weitershausen

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.

___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope )


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

2008-08-05 Thread Philipp von Weitershausen

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:




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.

___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope )