[Zope3-dev] what is ZCML?

Martijn Faassen faassen at infrae.com
Tue Mar 14 05:59:34 EST 2006


Jim Fulton wrote:
> Martijn Faassen wrote:
[snip]
>> as configuration in Python code is 
>> more flexible and packages can form a more self-contained whole.
> 
> 
> Wrong!
> 
> This is an important point. No one in the know is proposing
> using Python for configuration.  Python is for definition,
> not configuration.
> 
> The problem with some of the high-level ZCML directives is that
> they performed *definition* in addition to configuration.
> For example, browser:page creates new classes.
> 
> It's important that definition be done in Python. Configuration
> should be done in ZCML.

Okay, since I'm wrong, I think it would be useful if you spelled out the 
difference between definition and configuration. I have some intuitions 
but it's obviously not fully clear to me, and I suspect others may also 
have difficulty. I'll phrase give examples of things that I could 
interpret as configuration or as definition.

Which of the following is definition and which is configuration (or 
something else entirely?):

* Specifying which pages can be viewed for an object providing a 
particular interface.

* Attaching annotations to objects of a particular interface.

* Attaching menu entries to objects of a particular interface.

* Setting the layer a view is in.

* Specifying which page template is used to render a particular view.

* Setting the permissions needed to access the attributes of an object.

* Setting up the indexes in a catalog.

* Setting up a catalog for a site.

* Determine what is shown in which columns are shown in a table on a web 
page.

* The initial sorting order of these columns.

* The batch size of a particular batched view.

* Which resources should be included in a web page displaying a certain 
widget.

* The relational database we've connected our application to.

* The mailserver we've connected our application to.

* The fields that show up in a form.

* Setting up which fields that show up in a form are required.

* Setting up which file extensions we want to allow to be uploaded into 
a file upload widget.

Perhaps these questions are too high level and should be split up into 
multiple questions.

What criteria do you use to determine whether something is definition or 
configuration?

I also suspect that some of these are local or application specific 
configuration. It makes sense to store some configuration in the ZODB, 
and thus, at present, not express it in ZCML at all. What is 
configuration sometimes depends on the application in question.

> Should there be high-level directives in ZCML?  I don't think they should
> be disallowed, but you really have to ask yourself if the automation 
> they provide is worth the extra burden of understanding what they do.

The other drawback of using ZCML for automation is that complicated 
automation is often quite cumbersome to express in ZCML.

Another drawback is that such automation often combines various bits of 
python code with ZCML and you have to look at multiple files instead of 
just one.

> Anyway, the main thrust of the ZCML simplification is to use it just for
> low-level configuration, not for definition.

So to make it clear, you're in favor of ZCML interpretation #2, with the 
modification that Python code should not be used for configuration but 
definition. In the past, you as well were more thinking along the lines 
of interpretation #1, correct?

Regards,

Martijn


More information about the Zope3-dev mailing list