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>
链接
版权
本软件包版权由4teamwork所有。
《ftw.autofeature》采用GNU通用公共许可证,版本2。
变更日志
1.1.0 (2019-09-25)
添加Plone 5支持。[jone]
1.0.0 (2015-08-24)
初始实现[jone]
项目详情
关闭
ftw.autofeature-1.1.0.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 2a66da7842cf8dc5c5d548de9645fff2cb19bf48eea4113ea2e1398bed2fc5f5 |
|
MD5 | 5974a91c9983f2eaaec193d7ad513d4e |
|
BLAKE2b-256 | e6953d420a88be27076906d342763c040bb38c60eeec498acef59a09e6ebd376 |