[Zope3-dev] N-Tuple Adapters

Phillip J. Eby pje@telecommunity.com
Mon, 02 Jun 2003 23:06:50 -0400


At 09:49 PM 6/2/03 -0400, Shane Hathaway wrote:

> > So, again, defining the requirements precisely is important.  For example,
> > if different protocols really need different traversers, why not just 
> adapt
> > to different traversal interfaces?
>
>That's an interesting insight.  Adapters would provide IHTTPTraverser,
>IFTPTraverser, etc.  A problem arises, though, when you want to register
>and use a general ITraverser: getAdapter(foo, IHTTPTraverser) must never
>return an adapter registered as providing only ITraverser.  So either the
>adapter has to be registered many times (once for each traversal interface
>in the system) or we have to call getAdapter() multiple times, each time
>more general.

Unless I'm mistaken, I don't believe you would have that problem, if you 
had transitive adaptation.  That is, if you could register an adaptation 
from ITraverser to IHTTPTraverser that would automatically be selected, if 
there was an adaptation from the object to ITraverser.  My PyProtocols 
package has this capability; see 
http://peak.telecommunity.com/protocol_ref/proto-implication.html for the 
section of the reference that deals with "adapter paths" and relative 
precedence of different routes for an adaptation.  One of the (relatively) 
original contributions of PyProtocols is that it considers "implementing" 
an interface to be a special case of adaptation (the NO_ADAPTER_NEEDED 
adapter!), rather than the other way around.  This makes transitive 
adaptation and making new "subset" protocols (think reverse interface 
inheritance) easy and natural operations, not to mention fast.