[Zope3-dev] About zcml:condition

Jim Fulton jim at zope.com
Mon Jan 10 16:19:26 EST 2005


Martijn Faassen wrote:
> Hi,
> 
> This discussion was taking place on the zope3-checkins list, and I 
> didn't want it to be lost there without any public discussion.
> 
> Stephan Richter wrote:
> 
>> On Friday 07 January 2005 11:43, Fred L. Drake, Jr. wrote:
>>
>>> Log message for revision 28766:
>>>  Add ZCML support for conditional directives using the zcml:condition
>>>  attribute.  The value of the attribute is a TALES expression; if the
>>>  expression is true, the element the attribute is attached to will be
>>>  used, otherwise the element and its descendents will be ignored.
>>
>>
>>
>> I was waiting for the day when this would happen. Doesn't this violate 
>> the pricniple that we don't want to evolve ZCML to a language? The 
>> reason we chose ZCML over Python was that we did not want all the 
>> powerful features of a true programming language.
>>
> 
> To me this is a rather major conceptual change. My worries grow the more 
> I think about it.

I guess we we should have done a proposal ...

> I don't know anything about the details of how these TALES expressions 
> get evaluated (in what context, etc), so I may be misinterpreting this, 
> but:

They are pretty context free.  The use case was to only include
some zcml is running on windows.  I wanted the ability to
define variable and beable to conditionally configure based on those
variable, as in:

   zcml:condition"in_development|nothing"

to include things that should only be around during development.

> I am worried about allowing people to write Python code in ZCML. Only 
> allowing a simple expression language like path expressions, accessing 
> some predefined context, would be far more palatable to me. Python 
> conditionals could, by calling into a large codebase, affect some 
> arbitrary part of that codebase. Side effects might happen, errors could 
> occur.

Errors could occur lots of ways.  The intendion here is not to
perform lots of computation in zcml.

 > Python expressions also harm the processability of ZCML by
> external tools which want to do some analysis of ZCML code.

That would be true of a path-based syntax.

 > This
> includes Zope 3 source code analysis tools and authoring environments.
> 
> I'm therefore worried that Python expressions could compromise the 
> declarative nature of ZCML. I think that the genericity of using Python 
> in ZCML is a YAGNI; a simpler fix would be to have conditionals depend 
> on some simple, predefined and precalculated state that starts before 
> ZCML processing begins. This could include things like the platform.

Precalculated how?

Jim

-- 
Jim Fulton           mailto:jim at zope.com       Python Powered!
CTO                  (540) 361-1714            http://www.python.org
Zope Corporation     http://www.zope.com       http://www.zope.org


More information about the Zope3-dev mailing list