[Zope-dev] zope.component: calling an Interface and calling queryAdapter give differing results
Jim Fulton
jim at zope.com
Tue Aug 19 17:57:53 EDT 2008
On Aug 19, 2008, at 4:24 PM, Shane Hathaway wrote:
> Philipp von Weitershausen wrote:
>> Shane Hathaway wrote:
>>> Looks like a bug to me. If the object passed as the first
>>> argument to
>>> queryAdapter() implements the interface passed as the second
>>> argument, I
>>> believe queryAdapter() should return the object, regardless of any
>>> component registrations.
>>
>> 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 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).
Jim
--
Jim Fulton
Zope Corporation
More information about the Zope-Dev
mailing list