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

Dieter Maurer dieter at handshake.de
Sat Aug 23 07:23:15 EDT 2008


Jim Fulton wrote at 2008-8-19 17:57 -0400:
> ....
>> 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 is also a simpler  
>version of queryMultiAdapter, which looks up adapters for multiple  
>objects. In neither of these cases does it make sense to consider the  
>interfaces already provided by the object being adapted.  It makes no  
>sense to me for queryAdapter to have different semantics depending on  
>whether the name argument is provided (and is non-blank).

As the "implements" directive does not specify a name,
one could think that the default name is declared.
Then, your naming argument would go away.


As the "I(obj, ...)" syntax is more comfortable and more natural than
the "get[Multi]Adapter(obj, I, ...)", it may even be adequate
to give "I(...)" an optional "name" parameter.

Then, we could get rid of the "{get|query}[Multi]Adapter" altogether
and consistently use "I(....)" with appropriate optional parameters --
what a simplification and homogenization :-)



-- 
Dieter


More information about the Zope-Dev mailing list