2

我正在调查插件及其架构扩展器、接口、适配器、提供程序……但我不知道如何扩展扩展架构。我会更好地解释我的情况:

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

现在我要实现V,应该是H的扩展,实现如下结构:

L → H → V

插件“L”:

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

批处理.py

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

接口.py

class IBatch(Interfaces)

插件“H”</h2>

此插件从 L 获取内容类并对其进行扩展

批处理.py

from archetypes.schemaextender.interfaces import IOrderableSchemaExtender

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

配置.zcml

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

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

插件“L”:

批处理.py

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

接口.py

class IBatch(Interfaces)    

插件“H”</h2>

批处理.py

from archetypes.schemaextender.interfaces import IOrderableSchemaExtender

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

配置.zcml

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

接口.py

class IBatchH(Interface)

插件“V”:

批处理.py

from archetypes.schemaextender.interfaces import IOrderableSchemaExtender

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

接口.py

class IBatchV(Interface)

配置.zcml

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

正如您所期望的那样,它不起作用......但我不知道是否可以扩展扩展类。我必须指出,每个类都有自己的init,getFieldsgetOrder功能。如果我更改 V 插件上的适配定义,我会收到错误消息。V 插件中的每个函数都有一个 `pdb.set_trace() 定义,但实例不会停止......

编辑:我在这封邮件中发现:“你不能覆盖覆盖。你唯一的希望可能是 z3c.unconfigure:

http://pypi.python.org/pypi/z3c.unconfigure "

4

1 回答 1

2

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

在 V 中,你说

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

相应的类有一行:

适应(IBatchH)。

这可能是

adapts(L.interfaces.IBatch)

如果在 Plone 启动时有任何配置冲突,那么您需要在附加注册中添加一个 name="something_unique" 以消除冲突。

于 2015-04-21T12:23:27.280 回答