[Zope3-dev] N-Tuple Adapters

Shane Hathaway shane@zope.com
Mon, 2 Jun 2003 23:44:18 -0400 (EDT)


On Mon, 2 Jun 2003, Phillip J. Eby wrote:

> At 09:49 PM 6/2/03 -0400, Shane Hathaway wrote:
> >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 

We could do this today.  We'd register a special adapter for any object to
IHTTPTraverser.  The adapter factory would turn around and make a
recursive call to getAdapter().  Adapters for any object get lowest
priority, if I recall correctly.  Two downsides: the special adapter has
to be registered once per protocol, and you might get recursive loops.  
(Your documentation says PEAK eliminates the recursion problem.)

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

Whew, you like to turn everything on its head.  It sounds neat though. ;-)

I followed up to the last word.  How does this make it fast?  

Shane