Re: [Zope3-dev] reasonable syntax for multi-adaptation

2007-09-26 Thread Jim Fulton


On Sep 26, 2007, at 10:04 AM, Brandon Craig Rhodes wrote:


The current syntax for multi-adaptation makes the interface look like
an object of the adaptation, rather than the actor in the operation.
Instead, multi-adaption should look like this:

  IFoo(multi=(obj1, obj2))

or:

  IFoo(multi=(obj1, obj2), name='site_foo')


Ah, using keyword arguments to get around limitations (especially  
backward compatibility issues) with the current API is a neat idea.


If we were going to do this though, I think a method syntax would be  
cleaner.  As in:


  IFoo.adapt([ob1, ob2], 'site_foo', None)

Note that IFoo(ob) has some special semantics that don't apply to the  
multi- or named-adapter case. In particular:


- The object is returned if it already provides the interface, and

- The object's __conform__ method is used if it is present.

Neither of these make sense in the multi- or named-adapter cases.   
Given the differences in semantics, I wouldn't want to mix the APIs.


An added complication is that interfaces don't provide adaption  
directly, but via a hook. The existing hook api wouldn't work for  
mult or named adaptation, so a new hook would be needed.


While I can see benefit from having an interface method for doing  
multi and named adaptation, I don't think the benefit is worth the cost.


I'm -1 on your proposal and -0 on my variation. :)

Jim

--
Jim Fulton
Zope Corporation


___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com



[Zope3-dev] reasonable syntax for multi-adaptation

2007-09-26 Thread Brandon Craig Rhodes
The current syntax for multi-adaptation makes the interface look like
an object of the adaptation, rather than the actor in the operation.
Instead, multi-adaption should look like this:

  IFoo(multi=(obj1, obj2))

or:

  IFoo(multi=(obj1, obj2), name='site_foo')

The first draft of such an implementation could simply intercept a
"multi" keyword passed to InterfaceBasePy.__call__(), and hand control
over to the traditional getMultiAdapter.  The old getMultiAdapter call
should always remain available, but code will become much easier to
read as the new syntax is adopted and single- and multi-adaptation
become visually congruent.

I'll be happy to develop a patch and test cases.

-- 
Brandon Craig Rhodes   [EMAIL PROTECTED]   http://rhodesmill.org/brandon
___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com