[Zope3-dev] Re: Providing flexible adapters

Phillip J. Eby pje@telecommunity.com
Tue, 26 Feb 2002 11:01:12 -0500


At 10:40 AM 2/26/02 -0500, Shane Hathaway wrote:
>Zope 3's answer is to make a reference generation utility.  It would be a 
>very, very simple utility that might just look up an adapter.  If we later 
>decide that the adapter registry is sufficient, we can just leave it that 
>way.  If we instead decide that generating a reference depends on not just 
>the interfaces of the object, but also the interfaces of the object's 
>context (or something else), we can make a new service.

Interesting.  Are utilities placeful?

I'm not sure that putting the utility in front of the adapter gives any 
advantage for this situation, however.  One could always register an 
adapter that looked up the utility, right?  So if we expect the normal case 
to be just an adapter, it seems more straightforward to use the adapter, 
reducing the number of layers of delegation for the common case.


>Maybe this is the pattern: when you've made a decision, you write 
>software, but when you can't make a decision, you write configuration, 
>then write software that implements the decisions you might make.
>
>>This could be implemented by a small specialisation of the IToIRegistry.
>>If the IToIRegistry finds no better match for (ob_interface, provide), it 
>>returns the match for (ob_interface, None), if there is one.
>
>Actually, FYI you can already register an adapter that adapts anything, 
>using the value "None" as the object's interface.

Then maybe there should be an IReferenceable adapter that adapts anything, 
by looking up a placeful utility.  :)  Then we get two for the price of 
one, so to speak.  Ain't ZCA grand?  :)