在 Plone 4.3.3 下,我尝试在我的一个产品中自定义原型内容类型的类方法。
我有bsw.produit_1
一个内容类型MyContent
定义如下的产品:
class MyContent(base.ATCTContent):
implements(IMyContent)
meta_type = "MyContent"
schema = MyContent`
def ma_fonction(self):
......
return res
我想ma_fonction
在另一个产品中修改我的功能代码。我尝试使用适配器并遵循 plone 文档,但没有成功。
我希望自定义功能的类:
class CustomClass(object):
""" """
implements(IMyContent)
adapts(IMyContent)
def at_post_payment_script(self, obj_transaction):
""" """
......
# My new code
return res
configure.zcml
我声明我的适配器的地方:
<adapter for="bsw.produit_1.content.mycontent.MyContent"
provides="bsw.produit_1.interfaces.IMyContent"
factory=".customclass.CustomClass" />
在我的 zcml 声明中,我还尝试archetypes.schemaextender.interfaces.ISchemaExtender
使用 asprovides
或 put 接口IMyContent
而for
不是类。
这些都不起作用,每次都不会执行自定义代码。有人对此有解决方案吗?