[Zope-dev] zope.component: calling an Interface and calling queryAdapter give differing results

Shane Hathaway shane at hathawaymix.org
Tue Sep 9 15:44:11 EDT 2008


Philipp von Weitershausen wrote:
> El 9 Sep 2008, a las 20:37 , Dieter Maurer escribió:
>> But interfaces might grow an additional method, e.g. "adapt",
>> which could get the new signature.
>>
>> The syntax would be a bit more cumbersome -- but on the other
>> hand, it would be more explicit :-)
> 
> I don't think it would be too cumbersome. While IMHO elegant, the  
> current syntax of calling an interface to adapt isn't actually self- 
> explanatory. I've frequently observed people tripping over this,  
> specially when you have an IFoo interface and a Foo class -- which is  
> quite common --, then IFoo(obj) and Foo(obj) differ only by one  
> character. With your suggestion, it would be IFoo.adapt(obj) vs.  
> Foo(obj), making the difference quite obvious.
> 
> So overall I'm +1

+1 from me as well on IFoo.adapt() with the signature Chris suggested. 
"zope.component.getMultiAdapter()" is only easy to remember if you're a 
die-hard Zope coder, while IFoo.adapt() seems more useful to the larger 
Python community.

Shane



More information about the Zope-Dev mailing list