【问题标题】:How to extend an extended content type on Plone如何在 Plone 上扩展扩展内容类型
【发布时间】: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"
    />

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

编辑: 我在this mail 中找到:“你不能覆盖覆盖。你唯一的希望可能是 z3c.unconfigure:

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

【问题讨论】:

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


    【解决方案1】:

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

    在 V 中,你说的地方

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

    对应的类有一行:

    适应(IBatchH)。

    这可能是

    adapts(L.interfaces.IBatch)
    

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

    【讨论】:

    • 恕我直言,如果要使用多个 schemaextender 适配器,则必须使用命名适配器,否则会出现 ConfigurationConflictError。
    • 啊刚刚看到第二个更具体:-)
    猜你喜欢
    • 2011-01-21
    • 2010-12-26
    • 2014-11-15
    • 2012-11-14
    • 2012-02-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-29
    相关资源
    最近更新 更多