我正在尝试卸载collective.carousel
的原型schemaextender(我只对该包中的portlet感兴趣,而不是将Carousel源代码添加到每个PloneFormGen
字段等)。在
我尝试使用导入步骤注销适配器,但迄今为止失败。在
def unregister_carousel_extender(site):
from collective.carousel.schemaextender import ContentTypeExtender
from archetypes.schemaextender.interfaces import ISchemaExtender
from Products.ATContentType.interfaces import IATContentType
sm = site.getSiteManager()
sm.unregisterAdapter(factory=ContentTypeExtender, provided=(ISchemaExtender,), required=(IATContentType), name=u'')
我也曾在pdb呆过一段时间,但没有成功。我能够获得已注册的适配器,并且可以看到collective.carousel.schemaextender.ContentTypeExtender
注册为未命名的适配器。在
无法在导入步骤上注销。导入步骤仅在导入配置文件时运行。相反,zcml声明将在您启动实例时被解析和执行。因此,请确保在注册适配器之后,每隔一次注销。在
“required”参数需要是一系列接口,而不是单个接口。所以,required=[IATContentType]或required=(IATContentType,)(注意逗号!)而不是必需的=(IATContentType)。在
您可以检查unregisterAdapter的返回值,以确定它是否成功…如果为False,则说明它没有找到您指定的适配器(这通常意味着其中一个参数不正确)。在
你想要的是撤销集合.carousel当Zope启动时。您可以使用z3c.unconfigure包来完成此操作。在
(请注意,我不确定集合.carousel取消配置zcml的这一部分后仍然可以正常工作。)
相关问题 更多 >
编程相关推荐