質問
ZCMLフォームの条件ディレクティブを含むことができる
<configure zcml:condition="installed some.python.package">
(conditional configuration directives)
</configure>
condition
のための表現の構文は何ですか? 「または」許可されていますか。
解決
私はいつもあまりにもこれを見ています。私は怖い、構文は非常に簡単で、かつor
は構文の一部ではありません。
あなたから見ることができるように<のhref = "https://github.com/zopefoundation/zope.configuration/blob/4.0.3/src/zope/configuration/xmlconfig.py#L217-L256" のrel =」 noreferrer」タイトル= 『evaluateConditionソースコード』> zope.configurationソースコードでのドキュメントnofollowを、構文は常に動詞がverb arguments
、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>
所属していません StackOverflow