[Interface-dev] Twisted usage of zope interface in Zope3 SVN

Jim Fulton jim at zope.com
Mon Sep 25 10:17:09 EDT 2006


On Sep 22, 2006, at 5:08 PM, Christopher Armstrong wrote:

> On 9/22/06, Jim Fulton <jim at zope.com> wrote:
>
> Anyway, I'm glad you brought this up. I'd like to see this get  
> resolved.
>
>
>
> Thanks for the quick response, Jim. I've already updated the usage  
> of selfImplied to using the new registered() method.

Cool.

> We have one more problem, though: Apparently, __adapt__ methods on  
> Interface objects are no longer called during adaptation. This only  
> happens when using the C optimizations, and at first I thought this  
> didn't matter, because I was under the impression z.i didn't  
> actually care about PEP 246, but then I noticed that README.txt  
> explicitly talks about PEP 246 __adapt__ support.

Right. Interfaces provide an __adapt__ method ala PEP 246.  If you  
have an implementation of the PEP 246 adapt function, then interfaces  
should work with it.



> Now, if there is a method IFoo.__adapt__, and one calls IFoo(o),  
> that method will not be called when using the C optimizations,  
> because the C implementation of __call__ just directly calls the C  
> implementation of __adapt__ without looking it up as a method on  
> the interface object.
>
> Is this a bug?

No.  PEP 246 doesn't specify a protocol __call__ method so I don't  
feel bound by it.  I never considered it a use case to be able to  
override __adapt__ for interfaces.  If you want to do that, then  
you'll have to override __call__ as well.  Do you want to override  
__adapt__? If so, why?

Jim

--
Jim Fulton			mailto:jim at zope.com		Python Powered!
CTO 				(540) 361-1714			http://www.python.org
Zope Corporation	http://www.zope.com		http://www.zope.org





More information about the Interface-dev mailing list