質問

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 argumentshavenot-haveinstalledの一つであるフォームnot-installed、のである。

登録した機能の

havenot-haveテスト。登録特徴は、単に<meta:provides feature="something" />タグに登録されている不透明な文字列です。何かが特定の実装にそれを結びつけることなく、含まれていることをフラグにそれを使用してください。例:

<configure zcml:condition="have apidoc">
    <!-- only when the apidoc feature has been provided -->
</configure>

installednot-installedは単に名前のパッケージをインポートしてみてください。インポートが成功した場合ので、installedテストを行います。例:

<configure zcml:condition="installed sqlalchemy"> 
    <!-- only when the sqlalchemy module can be imported -->
</configure>
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top