[Zope3-dev] Re: adaptation based on class rather than interface

Lennart Regebro regebro at gmail.com
Mon Nov 13 10:31:49 EST 2006


On 11/13/06, Jean-Marc Orliaguet <jmo at ita.chalmers.se> wrote:
> Indeed technically yes. Practically not. I couldn't find many examples
> in the zope3 codebase that adapts classes.
> The #1 pattern is to adapt from interfaces, it appears as though there
> is a reason for it.

Yes, and I think both you and me mentioned it, but with different wordings.

If you specify it for a class, then only that class is adaptable. If
you want to use the adapter for yet another class, you have to
register it again. This is possible, but it's more flexible to specify
the adapter for an interface, and let all adaptable classes implement
that interface.

This is also a matter of specifying things for what they can do,
instead of for what they are, which you mentioned.

I'm not sure the proliferication (?) of marker interfaces is a big
risk. But if we get many of them, it still works better than the
options of magic __something__ attributes. :)

-- 
Lennart Regebro, Nuxeo     http://www.nuxeo.com/
CPS Content Management     http://www.nuxeo.org/


More information about the Zope3-dev mailing list