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

2024-06-10 02:20:07 发布

您现在位置:Python中文网/ 问答频道 /正文

我在调查插件和它们的模式扩展程序,接口,适配器,提供者。。。但是我找不到如何扩展扩展模式。我会更好地解释我的情况:

我有三个插件:L,H和V,其中L是“base”插件。所以H依赖于L的内容类型,因为它是L的扩展原型.schemaextender包裹。你知道吗

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

L→H→V

附加“L”:

此加载项的内容类型定义为类批处理(ATFolder)。这个插件也有自己的模式和它们的接口标记IcontentA。你知道吗

你知道吗批处理.py你知道吗

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

你知道吗接口.py你知道吗

class IBatch(Interfaces)

附加“H”

这个插件从L中获取content类并扩展它

你知道吗批处理.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”

你知道吗批处理.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"
    />

正如你所期待的那样,它不起作用。。。但我不知道是否有可能扩展一个扩展类。 我必须指出,每个类都有自己的initgetFieldsgetOrder函数。 如果我更改V addon上的adapts定义,我会得到一个错误。V addon中的每个函数都有一个`pdb.set\u跟踪()定义,但实例不停止。。。你知道吗

编辑时间: 我在this mail中发现:“不能重写重写。您唯一的希望可能是z3c.unconfigure:

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


Tags: frompy插件内容模式interfacesclassarchetypes
1条回答
网友
1楼 · 发布于 2024-06-10 02:20:07

为一个内容类型注册多个schemaextenders应该可以正常工作;我认为您在V中的注册是不正确的。你知道吗

在V里,你说

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

相应的类有以下行:

自适应(IBatchH)。你知道吗

这可能是

adapts(L.interfaces.IBatch)

如果在Plone启动时存在任何配置冲突,则需要向其他注册添加一个name=“something\u unique”来删除冲突。你知道吗

相关问题 更多 >