[Zope3-dev] Re: reasonable syntax for multi-adaptation
Martijn Faassen
faassen at startifact.com
Wed Sep 26 11:55:45 EDT 2007
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, 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
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.
Since Jim is -0 on his variation, he's not really against it, if someone
else does the work, right? :)
Regards,
Martijn
More information about the Zope3-dev
mailing list