[Interface-dev] Doing multi-adaptation through interface call (again)

Jp Calderone exarkun at divmod.com
Sat Aug 14 19:35:09 EDT 2004


Jim Fulton wrote:
> 
> I really like being able to do adaptation by calling
> interfaces.  Zope uses multi-adapters a fair bit.  These are
> adapters that adapt multiple objects.  They have a number of
> differences from single adapters:
> 
> [snip]
> 
> As mentioned here before, I'd like to be able to use tuples to
> indicate multi-adaptation in Zope:
> 
>   adapter = IFoo((a, b))
> 
> [snip]
> 
> Some alternatives (think of the above as alternative A):
> 
> B. Allow multiple arguments to __call__, as in:
> 
>      adapter = IFoo(a, b)
> 
>    This introduces 2 ambiguities:
> 
>    1. In a two argument case, we can't distinguish multi-adaptation
>       from single adaptation with a default.  We could fix this by
>       always requiring that the default be given as a keyword argument,
>       but that introduces a backward incompatability.
> 

   A similar solution would be to add a new keyword argument, "multi" or 
something, so that multiadaption looks like this:

     adapter = IFoo(a, b, multi=True)

   This preserves backwards compatibility, and is almost as nice as 
IFoo(a, b), I think.  The implementation would probably be weird.

   Don't have time to say more now, just wanted to throw the idea out there,

   Jp


More information about the Interface-dev mailing list