[Zope3-dev] Ranking adapters (2nd try)

Jim Fulton jim at zope.com
Tue Sep 30 14:56:37 EDT 2003


Steve Alexander wrote:
> Phillip J. Eby wrote:
> 
>> At 08:26 PM 9/30/03 +0300, Steve Alexander wrote:
>>
>>> I was suggesting that if I register locally an adapter to B2 that 
>>> this implies registration of that adapter to B1 and B0 also.
>>
>>
>> What happens if you *subsequently* register an adapter to B0?  Does it 
>> override the adapter declared to B2, where B0 is concerned?
> 
> 
> In my naive system, that sounds like a conflict.
> 
> <advocate owner="devil">
>   If you have the requirement to use different adapters to B0 and
>   to B2 at the same time, you have a "Liskov-fragile" system.
> </advocate>

I don't know what a "Liskov-fragile" system is. :)

Having different adapters for B0 and B2 seems very reasonable
to me.  Perhaps the adapter for B0 is "better" by some metric
(e.g. cheaper in some system resource). I also have an adapter
to B2 that is more expensive. I only want to use it when I need it.

Imagine that there is a B3:

   class B3(B0): pass

Now, I might want to have an adapter to B3. Is that in conflict with
the adapter for B2?  Well, yes. Most of the time, this doesn't matter.
If it did matter, I'd want to disambiguate by providing an explicit adapter
to B0, even if it required registering one of the other adapters twice.

> 
>> Unfortunately, not only is a ranking semantic needed, but the system 
>> must account for the effects of changes to the inputs of that ranking, 
>> as well as changes in the available adapters to be ranked.
> 
> 
> Only if you decide you need to register B0s and B2s with B0s being more 
> important than B2s. I haven't heard a good use-case for that on this 
> thread yet.

The best use case I can think of off-hand is the one I have above.
In some cases, it costs less to do less. In a case like this, I might
want to be able to offer a low-cost and low-functionality component
as well as a higher-cost higher-functionality one.

Jim

-- 
Jim Fulton           mailto:jim at zope.com       Python Powered!
CTO                  (540) 361-1714            http://www.python.org
Zope Corporation     http://www.zope.com       http://www.zope.org




More information about the Zope3-dev mailing list