我在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
Run Code Online (Sandbox Code Playgroud)
我想ma_fonction在另一个产品中修改我的功能代码.我尝试过使用适配器并遵循plone文档,但没有成功.
我希望自定义函数的类:
class CustomClass(object):
""" """
implements(IMyContent)
adapts(IMyContent)
def at_post_payment_script(self, obj_transaction):
""" """
......
# My new code
return res
Run Code Online (Sandbox Code Playgroud)
在configure.zcml这里,我宣布我的适配器:
<adapter for="bsw.produit_1.content.mycontent.MyContent"
provides="bsw.produit_1.interfaces.IMyContent"
factory=".customclass.CustomClass" />
Run Code Online (Sandbox Code Playgroud)
在我的ZCML声明,我也试图把archetypes.schemaextender.interfaces.ISchemaExtender作为provides或把接口IMyContent的for,而不是类.
这些都不起作用,每次都不会执行自定义代码.有人有解决方案吗?