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

Phillip J. Eby pje at telecommunity.com
Tue Sep 30 14:02:09 EDT 2003


At 08:48 PM 9/30/03 +0300, 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.

PyProtocols disagrees.  Instead, the new adapter takes precedence, because 
it has a shorter implication distance (zero) than the B2-B1-B0 adapter path 
(2 steps).  However, if you then register *another* adapter to B0, then 
that would conflict with the existing adapter, since the precedence is the 
same.

IOW, PyProtocols allows you to declare different adapters as long as they 
are at differing implication distances.  When the distance is the same, a 
conflict results.

Unfortunately, this isn't an option for Zope, since persistent interfaces 
may be changed over time.


>>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.

Um, suppose B1 stops implying B0?  Do you still have the B2 adapter 
registered for B0?  I don't think you want that.  I was speaking generally 
about the need for understanding the effects of changes in interface 
relationships to fully understand and properly implement an adapter 
precedence system.


>>Ideally, declaration/registration order should not have any effect on the 
>>resulting precedence(s).
>
>I agree.

Me too.  ;)




More information about the Zope3-dev mailing list