ZCML可以包含以下形式的条件指令
<configure zcml:condition="installed some.python.package">
(conditional configuration directives)
</configure>condition的表达式语法是什么?允许使用'or‘吗?
发布于 2009-10-21 19:58:48
我也总是要查这个。语法非常简单,恐怕or不是语法的一部分。
正如您从the documentation in the zope.configuration source code中看到的,语法始终是verb arguments的形式,其中verb是have、not-have、installed和not-installed之一。
注册功能的have和not-have测试。注册的功能只是一个使用<meta:provides feature="something" />标记注册的不透明字符串。使用它来标记已包含的内容,而无需将其绑定到特定的实现。示例:
<configure zcml:condition="have apidoc">
<!-- only when the apidoc feature has been provided -->
</configure>installed和not-installed只是尝试导入已命名的包;如果导入成功,则installed测试也会成功。示例:
<configure zcml:condition="installed sqlalchemy">
<!-- only when the sqlalchemy module can be imported -->
</configure>https://stackoverflow.com/questions/1596611
复制相似问题