小编Seb*_*ien的帖子

Plone 4:如何在Archetypes内容类型中自定义方法?

我在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或把接口IMyContentfor,而不是类.

这些都不起作用,每次都不会执行自定义代码.有人有解决方案吗?

plone adapter archetypes plone-4.x

3
推荐指数
1
解决办法
250
查看次数

标签 统计

adapter ×1

archetypes ×1

plone ×1

plone-4.x ×1