[英]What are the valid conditions for zcml:condition?
ZCML can include conditional directives of the form ZCML可以包含表单的条件指令
<configure zcml:condition="installed some.python.package">
(conditional configuration directives)
</configure>
What is the expression syntax for condition
? condition
的表达式语法是什么? Is 'or' allowed? 是'或'允许?
I always have to look this up too. 我也经常要这样看。 The syntax is very simple, and
or
is not part of the syntax, I am afraid. 我担心语法非常简单,
or
不是语法的一部分。
As you can see from the documentation in the zope.configuration source code , the syntax is always of the form verb arguments
, where verb is one of have
, not-have
, installed
and not-installed
. 正如你可以看到从在zope.configuration源代码文件 ,语法是永远的形式
verb arguments
,其中动词是一个have
, not-have
, installed
和not-installed
。
have
and not-have
test for a registered feature. have
not-have
注册的功能not-have
测试和not-have
测试。 A registered feature is simply an opaque string that has been registered with a <meta:provides feature="something" />
tag. 注册的功能只是一个不透明的字符串,已使用
<meta:provides feature="something" />
标记注册。 Use it to flag that something has been included without tying it to a particular implementation. 使用它来标记已包含的内容,而不将其绑定到特定实现。 Example:
例:
<configure zcml:condition="have apidoc">
<!-- only when the apidoc feature has been provided -->
</configure>
installed
and not-installed
simply try to import the named package; installed
和not-installed
只是尝试导入命名包; if the import succeeds so does the installed
test. 如果导入成功,那么
installed
测试也是如此。 Example: 例:
<configure zcml:condition="installed sqlalchemy">
<!-- only when the sqlalchemy module can be imported -->
</configure>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.