[Zope3-dev] RFC: zcml:condition

Martijn Faassen faassen at infrae.com
Fri Feb 18 09:35:11 EST 2005


Jim Fulton wrote:
> Martijn Faassen wrote:
> 
>> Jim Fulton wrote:
>> [snip]
>>
>>> Thoughts?

>> No objections to this design, but some questions about the decisions 
>> that went into the design.
>>
>> Not as powerful as before, which is good. External ZCML processors 
>> might mostly try to ignore this, 
> 
> Are there any?  I don't think so, so it's hard to imagine what they
> will do.

I wrote a Relax NG schema for ZCML once, so schema checking is one task.

Other potential uses could be:

* Getting some overview of declarations into your editor or IDE

* Pretty-print ZCML files

Here's an example of something that pretty prints ZCML:

http://rr.sodutch.com/media/code/python/zcml-xslt-20050115.zip

* Do some kind of checking of ZCML files, perhaps a dependency analysis, 
for instance.

I thought part of the idea of doing ZCML was that it at least opens up 
potentials for external tools that check this.

>> though that also depends on how conflicts are dealt with -- see my 
>> question below.
>>
>> I'm not sure about the 'verb arguments' construction -- is there a 
>> need for verbs or is this a YAGNI? Could you list some other potential 
>> verbs? 
> 
> 
> Yes, "if":
> 
>    zcml:condition="if .checkplatforms.validPlatform"

What does this do? What is a 'valid platform'?

Sounds like you could do it with zcml:condition="feature .."

zcml:condition="feature windows"

zcml:condition="feature linux"

of course people could write this:

zcml:condition="feature linux windows"

and try to mean 'linux' *or* 'windows' instead of 'linux *and* windows', 
which what it would mean in case of 'feature' (I think?), but the need 
to have 'or' is different from the need to have verbs. You could do it 
by linux_or_windows, though that'd be a hack. 'posix' would not be a 
hack though.

>> I can come up with 'nothave', not sure whether I can come up with 
>> applications for it. :)
>>
>> 'platform' might be a useful verb, perhaps. Then again, you could also 
>> work this with the semantics for 'have', I think, if you allow for 
>> featurenames to be specified *before* all ZCML processing starts.
> 
> I don't think this is workable.  It's hard to predict what a useful
> platform would be.

Huh? I just mean it needs to be known what platform the system is 
running on before ZCML processing starts and put these names into 
feature space.

>> Why the choice to make the verb be part of the attribute value, 
>> instead of having the verb *be* the attribute? i.e. you could have
>>
>> zcml:feature
>>
>> or zcml:hasfeature or zcml:iffeature
>>
>> or something along those lines.
>  
> Because I think the idea of a general condition is
> easier to understand than a number of similar features.
> 
> It is also similar to tal:condition, allowing people
> to leverage that knowledge.
> 
> I also think the verb-arguments format reads fairly well.

So then it depends on whether different verbs are needed at all. I'm 
rather intimidated by:

zcml:condition="if .checkplatforms.validPlatform"

right now. Perhaps after you explain what this could mean..

Oh, wait, does that mean look for the module .checkplatforms and then 
call validPlatform in it? I'm not sure whether that level of expressive 
power is needed as well -- it'd make ZCML hard to analyze without 
executing code, which is, as far as I know, currently not the case.

Though the recent addition of 'adapts()' and the like make ZCML harder 
to analyze independently as well...

Regards,

Martijn


More information about the Zope3-dev mailing list