[Zope3-dev] adaptation based on class rather than interface
Martijn Faassen
faassen at infrae.com
Thu Nov 9 10:20:05 EST 2006
Chris Withers wrote:
> Jim Fulton wrote:
>>> <adapter
>>> for=".myclasses.MyClass"
>>> provides=".interfaces.ISomething"
>>> factory=".adapters.MyAdapter"
>>> />
>>
>> I think it is a fine idea. That's why it has been supported for
>> a long time. You can register adapters and views (which, of course
>> are adapters) for classes as well as interfaces.
>
> Hmm, just to be clear:
>
> class A: pass
>
> class B(A): pass
>
> <adapter
> for="A"
> provides=".interfaces.ISomething"
> factory=".adapters.MyAdapter"
> />
>
> x = ISomething(B)
>
> ...will work, right?
>
Yes, that should work; it works for us this way in Grok. :)
As I said elsewhere, the only thing blocking usage of this in ZCML is
some directive which at least used to complain when you passed in a
class. That would be a bug.
Regards,
Martijn
More information about the Zope3-dev
mailing list