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