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

2007-09-28 Thread Jim Fulton
On Sep 28, 2007, at 11:14 AM, Martijn Faassen wrote: ... On 9/28/07, Jim Fulton [EMAIL PROTECTED] wrote: [snip] we could investigate whether we can't come up with something that: * doesn't break the existing notation. The cleanest way to support such non-interference seems to be to do this

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

2007-09-28 Thread Martijn Faassen
Hey, First: thanks for listening, Jim. On 9/28/07, Jim Fulton [EMAIL PROTECTED] wrote: [snip] we could investigate whether we can't come up with something that: * doesn't break the existing notation. The cleanest way to support such non-interference seems to be to do this using an extra

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

2007-09-28 Thread Martijn Faassen
Dominik Huber wrote: It would be great, if we could handle other adaption-derivations by the proposed unified, reasonable adaption-api too. [snip interesting proposal] Okay, so there seems to be quite a bit of consensus for *some* form of support for this. I've seen a number of proposals

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

2007-09-28 Thread Jim Fulton
On Sep 28, 2007, at 10:31 AM, Martijn Faassen wrote: Dominik Huber wrote: It would be great, if we could handle other adaption-derivations by the proposed unified, reasonable adaption-api too. [snip interesting proposal] Okay, so there seems to be quite a bit of consensus for *some* form

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

2007-09-27 Thread Dominik Huber
Brandon Craig Rhodes wrote: Tres Seaver [EMAIL PROTECTED] writes: Martijn Faassen wrote: IFoo.adapt() for normal adaptation IFoo.multiadapt() for multi adaptation I'd rather have 'adapt' take *args for the contexts, and keywords for extras (like name). And you could make the default=

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

2007-09-27 Thread Dominik Huber
Marius Gedminas wrote: On Wed, Sep 26, 2007 at 09:09:37PM -0400, Tres Seaver wrote: Why does the caller care? She just wants an object which will provide the 'IFoo' contract on behalf of the passed context. If 'x' is capable of providing 'IFoo' without help, then failing (or worse, returning

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

2007-09-26 Thread Brandon Craig Rhodes
Jim Fulton [EMAIL PROTECTED] writes: On Sep 26, 2007, at 10:04 AM, Brandon Craig Rhodes wrote: Instead, multi-adaption should look like this: IFoo(multi=(obj1, obj2)) IFoo(multi=(obj1, obj2), name='site_foo') Ah, using keyword arguments to get around limitations (especially backward

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

2007-09-26 Thread Jim Fulton
On Sep 26, 2007, at 11:08 AM, Brandon Craig Rhodes wrote: Jim Fulton [EMAIL PROTECTED] writes: On Sep 26, 2007, at 10:04 AM, Brandon Craig Rhodes wrote: Instead, multi-adaption should look like this: IFoo(multi=(obj1, obj2)) IFoo(multi=(obj1, obj2), name='site_foo') Ah, using

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

2007-09-26 Thread Martijn Faassen
Hey, My opinions: It'd be nice if getMultiAdapter's functionality was in reach without typing: import zope.component; zope.component.getMultiAdapter. The IFoo() single adapter lookup shows us a way to make this possible: a method (in this case __call__ on the interface). It does bother me on

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

2007-09-26 Thread Dieter Maurer
Jim Fulton wrote at 2007-9-26 11:29 -0400: ... IFoo(x) IBar(multi=(x,y)) Actually, that is not the case. If x already provides IFoo, then in the first case, the existing object is retuned. Nothing is instantiated. OTOH, in: getMultiAdapter([x], IFoo) or getAdapter(x,

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

2007-09-26 Thread Jim Fulton
On Sep 26, 2007, at 3:00 PM, Dieter Maurer wrote: Jim Fulton wrote at 2007-9-26 11:29 -0400: ... IFoo(x) IBar(multi=(x,y)) Actually, that is not the case. If x already provides IFoo, then in the first case, the existing object is retuned. Nothing is instantiated. OTOH, in:

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

2007-09-26 Thread Dieter Maurer
Jim Fulton wrote at 2007-9-26 15:10 -0400: ... Jim Fulton wrote at 2007-9-26 11:29 -0400: ... IFoo(x) IBar(multi=(x,y)) Actually, that is not the case. If x already provides IFoo, then in the first case, the existing object is retuned. Nothing is instantiated. OTOH, in:

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

2007-09-26 Thread Jim Fulton
On Sep 26, 2007, at 3:37 PM, Dieter Maurer wrote: Jim Fulton wrote at 2007-9-26 15:10 -0400: ... Jim Fulton wrote at 2007-9-26 11:29 -0400: ... IFoo(x) IBar(multi=(x,y)) Actually, that is not the case. If x already provides IFoo, then in the first case, the existing object is

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

2007-09-26 Thread Derek Richardson
To add a novice's perspective: When I first learned Zope, I tried the syntax: adapter = IFoo(context1, context2) It took me hours and the help of Philipp to determine why context2 was being returned. I saw the symmetry between IFoo(context) and a cast in other languages and figured I'd just

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

2007-09-26 Thread Stephan Richter
On Wednesday 26 September 2007 15:51, Derek Richardson wrote: As a more experienced Zope developer, I never make this mistake. But I still yearn for a simple syntax that makes multi-adaption as easy as adaption. While IFoo.adapt() and IFoo.multiadapt() are nice, neither is as simple as saying:

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

2007-09-26 Thread Tres Seaver
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Martijn Faassen wrote: Hey, My opinions: It'd be nice if getMultiAdapter's functionality was in reach without typing: import zope.component; zope.component.getMultiAdapter. The IFoo() single adapter lookup shows us a way to make this

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

2007-09-26 Thread Tres Seaver
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Jim Fulton wrote: On Sep 26, 2007, at 3:37 PM, Dieter Maurer wrote: Jim Fulton wrote at 2007-9-26 15:10 -0400: ... Jim Fulton wrote at 2007-9-26 11:29 -0400: ... IFoo(x) IBar(multi=(x,y)) Actually, that is not the case. If x already

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

2007-09-26 Thread Brandon Craig Rhodes
Tres Seaver [EMAIL PROTECTED] writes: Martijn Faassen wrote: IFoo.adapt() for normal adaptation IFoo.multiadapt() for multi adaptation I'd rather have 'adapt' take *args for the contexts, and keywords for extras (like name). And you could make the default= another possible extra! In

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

2007-09-26 Thread Marius Gedminas
On Wed, Sep 26, 2007 at 09:09:37PM -0400, Tres Seaver wrote: Why does the caller care? She just wants an object which will provide the 'IFoo' contract on behalf of the passed context. If 'x' is capable of providing 'IFoo' without help, then failing (or worse, returning a less-specific