[Zope-dev] implementing zope.component 4.0
chrism at plope.com
Sat Nov 28 11:26:18 EST 2009
Lennart Regebro wrote:
>> I have very much
>> come to appreciate the power of this delegation in, say, BrowserViews;
>> even if it did take me several months to understand the multiadapter
> I hear this a lot, so this is apparently something that is common to
> take a while to grasp. Any ideas of what to make multi-adapters more
> understandable would probably be a good thing.
The typical misunderstanding starts like this, I think:
- The developer performs some set of adapter registrations in setup.
- The developer wants to do an adapter lookup at runtime.
He often doesn't know which adapter he'll get back when he does a lookup,
especially when he registers a number of adapter factories for less specific
types than he wants to provide as "requires" lookup parameters.
Multiadapters add to the mystery because the relative order of the requires
arguments has an impact on which adapter is returned when there's more than one
candidate adapter factory.
This confusion comes about mostly because the algorithm that the registry uses
to choose an adapter factory (even for single-adaptation) is not documented or
specified in a consumable format anywhere.
Personally, even I don't really know how it works.
It would be useful if someone who did know how it worked created an analogue of
More information about the Zope-Dev