如何在Plone上扩展扩展内容类型

时间:2015-04-21 11:02:25

标签: python plone content-type archetypes plone-4.x

我正在调查插件及其架构扩展器,接口,适配器,提供程序......但我无法找到如何扩展扩展架构。我会更好地解释我的情况:

我有三个插件:L,H和V,其中L是“基础”插件。所以H依赖于L的内容类型,因为它是L的扩展。内容扩展是使用archetypes.schemaextender包进行的。

现在我想实现V,它应该是H的扩展,以实现以下结构:

L→H→V

Addon“L”:

此插件的内容类型定义为类Batch(ATFolder)。这个插件也有自己的架构和它们的接口标记IcontentA。

batch.py​​

class Batch(ATFolder):
    implements(IBatch)
    schema =....

interfaces.py

class IBatch(Interfaces)

Addon“H”

此插件从L获取内容类并将其扩展

batch.py​​

from archetypes.schemaextender.interfaces import IOrderableSchemaExtender

class BatchSchemaExtender(Object):
    adapts(IBatch)
    implements(IOrderableSchemaExtender)

configure.zcml中

<adapter factory=".batch.BatchSchemaExtender " />

好的,现在我想用另一个插件扩展内容的架构。我做过类似的事情:

Addon“L”:

batch.py​​

class Batch(ATFolder):
    implements(IBatch)
    schema =....

interfaces.py

class IBatch(Interfaces)    

Addon“H”

batch.py​​

from archetypes.schemaextender.interfaces import IOrderableSchemaExtender

class BatchSchemaExtender(Object):
    adapts(IBatch)
    implements(IOrderableSchemaExtender,  IBatchH)

configure.zcml中

<adapter factory=".batch.BatchSchemaExtender”
provides=”archetypes.schemaextender.interfaces.IOrderableSchemaExtender" />

interfaces.py

class IBatchH(Interface)

Addon“V”:

batch.py​​

from archetypes.schemaextender.interfaces import IOrderableSchemaExtender

class BatchV(Object):
    adapts(IBatchH)
    implements(IOrderableSchemaExtender,  IbatchV)

interfaces.py

class IBatchV(Interface)

configure.zcml中

<adapter
    for="L.interfaces.IBatch"
    provides="archetypes.schemaextender.interfaces.IOrderableSchemaExtender"
    factory=".batch.BatchV"
    />

正如您所期望的那样,它不起作用......但我不知道是否可以扩展一个扩展课程。 我必须说明每个类都有自己的initgetFieldsgetOrder函数。 如果我在V插件上更改自适应定义,我会收到错误。 V addon中的每个函数都有一个`pdb.set_trace()定义,但实例并没有停止......

EDITED: 我在this mail中找到了:&#34;您无法覆盖覆盖。你唯一的希望可能是z3c.unconfigure:

http://pypi.python.org/pypi/z3c.unconfigure &#34;

1 个答案:

答案 0 :(得分:2)

为单个内容类型注册多个schemaextender应该按预期工作;我认为您在V中的注册不正确。

在V中,你说

<adapter
    for="L.interfaces.IBatch"
    provides="archetypes.schemaextender.interfaces.IOrderableSchemaExtender"
    factory=".batch.BatchV"
/>

相应的类有以下行:

适应(IBatchH)。

这可能是

adapts(L.interfaces.IBatch)

如果Plone启动时有任何配置冲突,那么你需要添加一个名称=&#34; something_unique&#34;其他注册以消除冲突。

相关问题