【发布时间】:2015-06-28 12:07:54
【问题描述】:
我正在调查插件及其架构扩展器、接口、适配器、提供程序……但我不知道如何扩展扩展架构。我会更好地解释我的情况:
我有三个插件: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 =....
interfaces.py
class IBatch(Interfaces)
插件“H”
此插件从 L 获取内容类并对其进行扩展
批处理.py
from archetypes.schemaextender.interfaces import IOrderableSchemaExtender
class BatchSchemaExtender(Object):
adapts(IBatch)
implements(IOrderableSchemaExtender)
configure.zcml
<adapter factory=".batch.BatchSchemaExtender " />
好的,现在我想用另一个插件扩展内容的架构。我做了类似的事情:
插件“L”:
批处理.py
class Batch(ATFolder):
implements(IBatch)
schema =....
interfaces.py
class IBatch(Interfaces)
插件“H”
批处理.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)
插件“V”:
批处理.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"
/>
正如您所期望的那样,它不起作用...但是我不知道是否可以扩展扩展类。
我必须指出,每个类都有自己的init、getFields 和getOrder 函数。
如果我更改 V 插件上的适配定义,我会收到错误消息。 V addon 中的每个函数都有一个`pdb.set_trace() 定义,但实例并没有停止...
编辑: 我在this mail 中找到:“你不能覆盖覆盖。你唯一的希望可能是 z3c.unconfigure:
【问题讨论】:
标签: python plone content-type archetypes plone-4.x