跳转到主要内容

ftw.autofeature 自动注册ZCML功能。

项目描述

ftw.autofeature 自动注册ZCML功能。

附加功能

《autofeature:extras》指令会自动为每个附加(`extras_requires`)注册ZCML功能。当附加的每个依赖项安装时,将自动提供附加的功能。

示例

当有一个如下的setup.py文件

from setuptools import setup, find_packages

setup(name='my.package',
      version='1.0.0dev0',
      packages=find_packages(exclude=['ez_setup']),
      namespace_packages=['my'],
      install_requires=[
          'setuptools',
          'ftw.autofeature',
      ],

      extras_require={
          'tests': ['unittest2'],
          'foo': ['foo', 'foo-compat'],
          'bar': ['bar', 'bar-compat']})

您可以让`ftw.autofeature`自动为您的附加功能声明功能

<configure
    xmlns="http://namespaces.zope.org/zope"
    xmlns:zcml="http://namespaces.zope.org/zcml"
    xmlns:autofeature="http://namespaces.zope.org/autofeature">

    <include package="ftw.autofeature" file="meta.zcml" />
    <autofeature:extras />

    <configure zcml:condition="have my.package:foo">
        <!-- foo things -->
    </configure>

    <configure zcml:condition="have my.package:bar">
        <!-- bar things -->
    </configure>

    <configure zcml:condition="have my.package:foo:bar">
        <!-- foo and bar things -->
    </configure>

</configure>

只有当附加功能安装时,`my.package:foo`功能才会被注册。当同时安装`foo`和`bar`时,会注册多个功能,以便轻松地将附加功能与`AND`组合

  • my.package:foo

  • my.package:foo:bar

  • my.package:bar

  • my.package:bar:foo

限制

我们实际上无法检测到附加功能是否在安装时明确使用。因此,我们测试附加功能中的每个依赖项是否已安装。当每个依赖项都已安装,但没有明确安装附加功能时,这将因此也会注册该功能。

转储功能

《autofeature:dump》指令将当前注册的ZCML功能转储到标准输出。只需使用该指令在任何ZCML点转储功能即可。

<configure
    xmlns="http://namespaces.zope.org/zope"
    xmlns:autofeature="http://namespaces.zope.org/autofeature">

    <include package="ftw.autofeature" file="meta.zcml" />
    <autofeature:dump />

</configure>

变更日志

1.1.0 (2019-09-25)

  • 添加Plone 5支持。[jone]

1.0.0 (2015-08-24)

  • 初始实现[jone]

项目详情


下载文件

下载适合您平台的文件。如果您不确定该选择哪个,请了解有关安装包的更多信息。

源代码发行版

ftw.autofeature-1.1.0.tar.gz (13.9 kB 查看哈希值)

上传时间 源代码

由以下支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误日志 StatusPage StatusPage 状态页