On Sat, May 05, 2007 at 02:07:58PM +0200, Dominique Lederer wrote:
> i just tried to adapt an object with two similar interfaces:
> 
> class IBaseAdapter(Interface):
>       content = Text(title=u"Content", required=False)
> 
> class IHomeAdapter(IBaseAdapter):
>     """ """
> class ILinksAdapter(IBaseAdapter):
>     """ """
> 
> after that, i created two formlib editform views and registered them on my
> adapted object. The "content" property is saved on different annotation keys 
> on
> the adapted object. The form renders correctly, but the "content" property is
> only handled via the ILinksAdapter by formlib. so content is saved always on 
> the
> same annotation key.
> 
> if i change my interfaces to
> class IHomeAdapter(Interface):
>     content = Text(title=u"Content", required=False)
> class ILinksAdapter(Interface):
>     content = Text(title=u"Content", required=False)
> 
> formlib works and uses the two different adapters implementations.
> 
> looks like a bug, can somebody confirm or comment this?

In your first example the same form field is shared by the three
interfaces (through inheritance).  The field itself knows that it is
part of IBaseAdapter, so formlib tries to adapt your content object to
IBaseAdapter in both cases (and zope.component gives it the
IHomeAdapter, because that's the first one that satisfies the
IBaseAdapter requirement).

I don't know if this is a bug, or if it's supposed to be that way.
It would be very hard to change the behaviour, I expect.

Marius Gedminas
-- 
Funny off-topic messages are always on-topic.

Attachment: signature.asc
Description: Digital signature

_______________________________________________
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users

Reply via email to