在configure.zcml
我有:
<adapter name="getCountry" factory=".extender.country_indexer" />
在extender.py
我有:
@indexer(IATFile)
@indexer(IATImage)
@indexer(IProject)
@indexer(IATDocument)
def country_indexer(context):
return _country_indexer(context)
但这并没有将所有这些类型都分类到getCountry
索引下。你知道吗
如果我注释掉除一个装饰器以外的所有装饰器,它适用于该类型。你知道吗
我怎样才能把它们全部编目?你知道吗
更多信息。只有一个注册是用适当的callable调用的。其他的用DelegatingIndexerFactory调用:
indexer.__init__ <plone.indexer.decorator.indexer instance at 0xafa6998> (<InterfaceClass Products.ATContentTypes.interfaces.file.IATFile>,)
indexer.__init__ <plone.indexer.decorator.indexer instance at 0xafa6f80> (<InterfaceClass Products.ATContentTypes.interfaces.image.IATImage>,)
indexer.__init__ <plone.indexer.decorator.indexer instance at 0xafa8050> (<InterfaceClass project.interfaces.project.IProject>,)
indexer.__init__ <plone.indexer.decorator.indexer instance at 0xafa8128> (<InterfaceClass Products.ATContentTypes.interfaces.document.IATDocument>,)
indexer.__call__ <plone.indexer.decorator.indexer instance at 0xafa8128> <function country_indexer at 0xafa76e0>
indexer.__call__ <plone.indexer.decorator.indexer instance at 0xafa8050> <plone.indexer.delegate.DelegatingIndexerFactory object at 0xafa5910>
indexer.__call__ <plone.indexer.decorator.indexer instance at 0xafa6f80> <plone.indexer.delegate.DelegatingIndexerFactory object at 0xafa5b90>
indexer.__call__ <plone.indexer.decorator.indexer instance at 0xafa6998> <plone.indexer.delegate.DelegatingIndexerFactory object at 0xafa5910>
恐怕
@indexer
装饰程序不支持链接。你知道吗有几种可能的解决方案:
1。标记接口(我最喜欢)
用单独的标记接口标记支持
_country_indexer
的内容。 例如ICountry
?你知道吗这可以通过ZCML实现:
然后将此接口用于
indexer
2。在
Interface
上注册并将逻辑直接实现到方法中:三。多次复制代码
zcml部分:
相关问题 更多 >
编程相关推荐