Reputation: 55
I was investigating about addons and their schema extenders, interfaces, adapters, providers... but I cannot find out how to extend an extended schema. I'll explain my situation better:
I have three addons: L, H and V where L is the “base” addon. So H depends on L's content types because it's an extension of L. The content extensions was made using archetypes.schemaextender package.
Now I want to implement V, it should be an extension of H to achieve the following structure:
L → H → V
This addon has a content type defined as class Batch(ATFolder). This addon also has its own schema and their interface marker IcontentA.
batch.py
class Batch(ATFolder):
implements(IBatch)
schema =....
interfaces.py
class IBatch(Interfaces)
This addon obtains the content class from L and extends it
batch.py
from archetypes.schemaextender.interfaces import IOrderableSchemaExtender
class BatchSchemaExtender(Object):
adapts(IBatch)
implements(IOrderableSchemaExtender)
configure.zcml
<adapter factory=".batch.BatchSchemaExtender " />
Ok, now I want to extend the content's schema with another addon. I've done something like:
batch.py
class Batch(ATFolder):
implements(IBatch)
schema =....
interfaces.py
class IBatch(Interfaces)
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)
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"
/>
As you are expecting it doesn't work... But I don't know if it's possible to extend an extended class.
I have to remark that each class has its own init
, getFields
and getOrder
functions.
If I change the adapts definition on V addon I gets an error. Each function inside V addon has an `pdb.set_trace() definition, but the instance doesn't stops...
EDITED: I found in this mail: "You can't override an override. Your only hope may be z3c.unconfigure:
http://pypi.python.org/pypi/z3c.unconfigure "
Upvotes: 2
Views: 178
Reputation: 725
Registering multiple schemaextenders for a single content type should work as expected; I think your registration in V is incorrect.
in V, where you say
<adapter
for="L.interfaces.IBatch"
provides="archetypes.schemaextender.interfaces.IOrderableSchemaExtender"
factory=".batch.BatchV"
/>
the corresponding class has the line:
adapts(IBatchH).
This could be
adapts(L.interfaces.IBatch)
If there are any configuration conflicts when Plone is starting, then you need to add a name="something_unique" to additional registrations to remove the conflicts.
Upvotes: 2