On Aug 11, 2008, at 3:10 PM, Hedley Roos wrote:

Hi all

A brief example...

Class Triangle subclasses Shape.

In my zcml I have

<adapter
 factory=".shape.ShapeExtender"
 for="Products.MyProduct.content.shape.Shape"
 name="shape-extender"/>
<adapter
 factory=".triangle.TriangleExtender"
 for="Products.MyProduct.content.triangle.Triangle"
 name="triangle-extender"/>

I find that schemaextender tries to call the extender for Shape even
when I am looking (eg. base_edit'ing) at a Triangle instance. This
causes problems with the getOrder method since Shape is not supposed
to know about Triangle's fields.

In extender.py method instanceSchemaFactory we have extenders =
list(getAdapters((context,), ISchemaModifier)) and that returns both
extenders. Is it supposed to do that? And if so is there a zcml
directive which can solve my problem?

My current horrid workaround is to abuse the resolution order and name
the triangle adapter "atriangle-extender".

Why don't you just name both adapters "shape-adapter"? Then the adapter lookup will only find the "shape-adapter" registered for the most specific interface that your content type implements. (I'm not sure whether or not this will work when registering the adapters for classes, but it will certainly work if you register them for an IShape interface and an ITriangle interface, which are implemented by the Shape and Triangle classes respectively, and where ITriangle extends IShape.)

David Glick
Project Associate
ONE/Northwest

New tools and strategies for engaging people in protecting the environment

http://www.onenw.org
[EMAIL PROTECTED]
(206) 286-1235 x32

Subscribe to ONEList, our email newsletter!
Practical advice for effective online engagement
http://www.onenw.org/full_signup




_______________________________________________
Product-Developers mailing list
[email protected]
http://lists.plone.org/mailman/listinfo/product-developers

Reply via email to