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

Shane Hathaway shane at hathawaymix.org
Tue Aug 19 20:36:00 EDT 2008


Chris Withers wrote:
> Jim Fulton wrote:
>>>> No, it's not a bug. This is in fact a feature (like it or not).
>>> While I respect that this feature may have been chosen carefully, it
>>> nevertheless seems more like a misfeature.  Chris' expectation was
>>> reasonable and ought not to be violated without a good cause.
>> queryAdapter is used to look up named adapters. 
> 
> It sure would be nice if it had a docstring that at least indicated that 
> was its only intended purpose.

Now would be a good time for you to add that docstring to the trunk. :-)

>  From a use point of view, I'd only expect queryAdapter to consider 
> looking for a named adapter if I actually provide a name. If I provide 
> no name, it would seem logical to look up a non-named adapter. If 
> looking up a non-named adapter, it would make sense if the object 
> already provides the desired interfaces to just return the object.
> 
> I'd love to see where this expectation is faulty...

I'm switching to Jim's side now. :-)  The semantics you described are 
more magical.  At this point it's probably better to just improve the docs.

Shane


More information about the Zope-Dev mailing list