What are the valid conditions for zcml:condition?

前端 未结 1 1250
庸人自扰
庸人自扰 2020-12-17 23:29

ZCML can include conditional directives of the form


    (conditional configuration directi         


        
相关标签:
1条回答
  • 2020-12-17 23:59

    I always have to look this up too. The syntax is very simple, and or is not part of the syntax, I am afraid.

    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.

    have and not-have test for a registered feature. A registered feature is simply an opaque string that has been registered with a <meta:provides feature="something" /> tag. 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; if the import succeeds so does the installed test. Example:

    <configure zcml:condition="installed sqlalchemy"> 
        <!-- only when the sqlalchemy module can be imported -->
    </configure>
    
    0 讨论(0)
提交回复
热议问题