Hash: SHA1

Martijn Faassen wrote:
> Hey,
> My opinions:
> It'd be nice if getMultiAdapter's functionality was in reach without 
> typing: import zope.component; zope.component.getMultiAdapter. The 
> IFoo() single adapter lookup shows us a way to make this possible: a 
> method (in this case __call__ on the interface). It does bother me on 
> occasion that I need to invoke multi adaptation in such an entirely 
> different way. I must also note that it's a very common intuition to 
> want to do something like IFoo((a, b)).
> Even though  my intuition is usually like Jim's and prefer to have two 
> different methods, given different semantics, I consider the differences 
>   in semantics here such a grey area I'm on the fence.
> That the object itself is returned if it already provides the interface 
> in single adaptation is a difference in semantics,

The fact that the object may be returened as its own adapter is
logically opaque to the caller, who should properly care only that the
returned value implements the interface.  For exactly the same reason, I
think that calling an iterface with an *empty* context list could
reasonablly be construed as a 'getUtility' request:  the fact that a
factory is called for one, and not the other, is irrelevant *to the caller*.

> but since there's 
> just no possibility of doing so in the case of multi adaptation anyway, 
> you can argue whether this is a difference in semantics or not, just 
> some semantics that doesn't apply. __conform__ is a bigger difference, 
> but given that polymorphism abounds in object oriented code, having 
> different behavior with different inputs is not *that* surprising either.


> Anyway, if we want to split methods, I'm fine with a properly named 
> method for multi-adaptation on the interface. For completeness' sake 
> you'd also want a properly named method on the interface for 
> single-adaptation.
> IFoo.adapt() for normal adaptation
> IFoo.multiadapt() for multi adaptation

I'd rather have 'adapt' take *args for the contexts, and keywords for
extras (like name).

> sound reasonable to me. We then explain that if you call IFoo directly, 
> IFoo.adapt is called. These could then also be extended to support named 
> adapter lookup and such.

- --
Tres Seaver          +1 540-429-0999          [EMAIL PROTECTED]
Palladion Software   "Excellence by Design"    http://palladion.com
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

Zope3-dev mailing list
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com

Reply via email to