Re: [Zope-dev] zope.component: calling an Interface and calling queryAdapter give differing results

2008-10-03 Thread Chris Withers
Tres Seaver wrote: >> I guess it must be, since calling an interface already does some adaptation. > > No, there is no dependency: zope.interface defines a hook point that > zope.component uses. In the absence of zope.component, zope.interface > uses a default implementation. That sound pretty

Re: [Zope-dev] zope.component: calling an Interface and calling queryAdapter give differing results

2008-09-30 Thread Dieter Maurer
Chris Withers wrote at 2008-9-22 19:41 +0100: >Shane Hathaway wrote: >> +1 from me as well on IFoo.adapt() with the signature Chris suggested. >> "zope.component.getMultiAdapter()" is only easy to remember if you're a >> die-hard Zope coder, while IFoo.adapt() seems more useful to the larger >>

Re: [Zope-dev] zope.component: calling an Interface and calling queryAdapter give differing results

2008-09-30 Thread Tres Seaver
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Chris Withers wrote: > Brandon Craig Rhodes wrote: >> I'm encouraged by the fact that this time it looks like people with time >> are interested enough to actually begin producing code? At the time >> that I made the 2007 proposal I was still very new

Re: [Zope-dev] zope.component: calling an Interface and calling queryAdapter give differing results

2008-09-30 Thread Chris Withers
Brandon Craig Rhodes wrote: > I'm encouraged by the fact that this time it looks like people with time > are interested enough to actually begin producing code? At the time > that I made the 2007 proposal I was still very new to the code base and > never got the courage up (or time available) to s

Re: [Zope-dev] zope.component: calling an Interface and calling queryAdapter give differing results

2008-09-26 Thread Brandon Craig Rhodes
Shane Hathaway <[EMAIL PROTECTED]> writes: > Philipp von Weitershausen wrote: >> >> So overall I'm +1 > > +1 from me as well on IFoo.adapt() with the signature Chris suggested. > "zope.component.getMultiAdapter()" is only easy to remember if you're a > die-hard Zope coder, while IFoo.adapt() se

Re: [Zope-dev] zope.component: calling an Interface and calling queryAdapter give differing results

2008-09-22 Thread Chris Withers
Shane Hathaway wrote: > +1 from me as well on IFoo.adapt() with the signature Chris suggested. > "zope.component.getMultiAdapter()" is only easy to remember if you're a > die-hard Zope coder, while IFoo.adapt() seems more useful to the larger > Python community. So if we're all in agreement, wh

Re: [Zope-dev] zope.component: calling an Interface and calling queryAdapter give differing results

2008-09-22 Thread Chris Withers
Philipp von Weitershausen wrote: > So overall I'm +1 Me too! Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo

Re: [Zope-dev] zope.component: calling an Interface and calling queryAdapter give differing results

2008-09-09 Thread Shane Hathaway
Philipp von Weitershausen wrote: > El 9 Sep 2008, a las 20:37 , Dieter Maurer escribió: >> But interfaces might grow an additional method, e.g. "adapt", >> which could get the new signature. >> >> The syntax would be a bit more cumbersome -- but on the other >> hand, it would be more explicit :-) >

Re: [Zope-dev] zope.component: calling an Interface and calling queryAdapter give differing results

2008-09-09 Thread Philipp von Weitershausen
El 9 Sep 2008, a las 20:37 , Dieter Maurer escribió: > Chris Withers wrote at 2008-9-8 18:34 +0100: >> ... >>> There's the backward-compatibility issue, which is a showstopper. >>> There's plenty of code that does this: >>> >>>adapter = package.interfaces.IFoo(object, None) >>> >>> Changing the

Re: [Zope-dev] zope.component: calling an Interface and calling queryAdapter give differing results

2008-09-09 Thread Fred Drake
On Tue, Sep 9, 2008 at 2:37 PM, Dieter Maurer <[EMAIL PROTECTED]> wrote: > The syntax would be a bit more cumbersome -- but on the other > hand, it would be more explicit :-) Seems to me zope.component.getMultiAdapter(...) is sufficient as-is, and shares the benefit of explicitness. That's suffic

Re: [Zope-dev] zope.component: calling an Interface and calling queryAdapter give differing results

2008-09-09 Thread Dieter Maurer
Chris Withers wrote at 2008-9-8 18:34 +0100: > ... >> There's the backward-compatibility issue, which is a showstopper. >> There's plenty of code that does this: >> >> adapter = package.interfaces.IFoo(object, None) >> >> Changing the signature as you describe would break all code that does t

Re: [Zope-dev] zope.component: calling an Interface and calling queryAdapter give differing results

2008-09-08 Thread Chris Withers
Fred Drake wrote: > On Sun, Sep 7, 2008 at 3:29 PM, Chris Withers <[EMAIL PROTECTED]> wrote: >> I can't see any problems with this, can anyone else? > > There's the backward-compatibility issue, which is a showstopper. > There's plenty of code that does this: > > adapter = package.interfaces.

Re: [Zope-dev] zope.component: calling an Interface and calling queryAdapter give differing results

2008-09-08 Thread Shane Hathaway
Chris Withers wrote: > Philipp von Weitershausen wrote: >>> Right, but how do you differentiate adapting a tuple to IBrowserPage >>> versus adapting obj and request together to IBrowserPage? >> You don't, I guess. I'd say that multi-adaption is *defined* as the >> adaption of a tuple. > > Well

Re: [Zope-dev] zope.component: calling an Interface and calling queryAdapter give differing results

2008-09-08 Thread Fred Drake
On Sun, Sep 7, 2008 at 3:29 PM, Chris Withers <[EMAIL PROTECTED]> wrote: > I can't see any problems with this, can anyone else? There's the backward-compatibility issue, which is a showstopper. There's plenty of code that does this: adapter = package.interfaces.IFoo(object, None) Changing th

Re: [Zope-dev] zope.component: calling an Interface and calling queryAdapter give differing results

2008-09-08 Thread Chris Withers
Philipp von Weitershausen wrote: >> Right, but how do you differentiate adapting a tuple to IBrowserPage >> versus adapting obj and request together to IBrowserPage? > > You don't, I guess. I'd say that multi-adaption is *defined* as the > adaption of a tuple. Well no, I think Dieter suggeste

Re: [Zope-dev] zope.component: calling an Interface and calling queryAdapter give differing results

2008-09-02 Thread Stephan Richter
On Tuesday 02 September 2008, Martin Aspeli wrote: > > Some people who use zope.interface reply on being able to singly adapt   > > tuples > > I've heard this before, but I've always been curious: why? when is this > a pattern you'd want to use? Ask the twisted guys. :-) Regards, Stephan -- Step

Re: [Zope-dev] zope.component: calling an Interface and calling queryAdapter give differing results

2008-09-02 Thread Martin Aspeli
Jim Fulton wrote: > Some people who use zope.interface reply on being able to singly adapt > tuples I've heard this before, but I've always been curious: why? when is this a pattern you'd want to use? Martin -- Author of `Professional Plone Development`, a book for developers who want to wo

Re: [Zope-dev] zope.component: calling an Interface and calling queryAdapter give differing results

2008-09-02 Thread Jim Fulton
On Sep 1, 2008, at 12:33 PM, Philipp von Weitershausen wrote: > El 1 Sep 2008, a las 17:23 , Chris Withers escribió: >> Philipp von Weitershausen wrote: >>> I've personally thought for some time that it would be quite nice >>> if all you had to do was call an interface to look up a utility >>> (

Re: [Zope-dev] zope.component: calling an Interface and calling queryAdapter give differing results

2008-09-01 Thread Philipp von Weitershausen
El 1 Sep 2008, a las 19:26 , Dieter Maurer escribió: > Chris Withers wrote at 2008-9-1 16:23 +0100: >> ... >>> auth = IAuthentication() # utility >>> auth = IAuthentication(default=None) >>> langs = IUserPreferredLanguages(request) # adapter >>>

Re: [Zope-dev] zope.component: calling an Interface and calling queryAdapter give differing results

2008-09-01 Thread Dieter Maurer
Chris Withers wrote at 2008-9-1 16:23 +0100: > ... >>auth = IAuthentication() # utility >>auth = IAuthentication(default=None) >>langs = IUserPreferredLanguages(request) # adapter >>langs = IUserPreferredLanguages(request, default=None

Re: [Zope-dev] zope.component: calling an Interface and calling queryAdapter give differing results

2008-09-01 Thread Dieter Maurer
Philipp von Weitershausen wrote at 2008-9-1 14:07 +0200: > ... >I've personally thought for some time that it would be quite nice if >all you had to do was call an interface to look up a utility (which is >sort of a multi-adapter of order 0) or to do some kind of adaption, no >matter how many

Re: [Zope-dev] zope.component: calling an Interface and calling queryAdapter give differing results

2008-09-01 Thread Philipp von Weitershausen
El 1 Sep 2008, a las 17:23 , Chris Withers escribió: > Philipp von Weitershausen wrote: >> I've personally thought for some time that it would be quite nice >> if all you had to do was call an interface to look up a utility >> (which is sort of a multi-adapter of order 0) or to do some kind

Re: [Zope-dev] zope.component: calling an Interface and calling queryAdapter give differing results

2008-09-01 Thread Chris Withers
Philipp von Weitershausen wrote: > I've personally thought for some time that it would be quite nice if > all you had to do was call an interface to look up a utility (which is > sort of a multi-adapter of order 0) or to do some kind of adaption, no > matter how many objects you wanted to ada

Re: [Zope-dev] zope.component: calling an Interface and calling queryAdapter give differing results

2008-09-01 Thread Philipp von Weitershausen
El 30 Aug 2008, a las 07:50 , Dieter Maurer escribió: > Chris Withers wrote at 2008-8-29 10:25 +0100: >> Dieter Maurer wrote: >>> Then, we could get rid of the "{get|query}[Multi]Adapter" altogether >>> and consistently use "I()" with appropriate optional >>> parameters -- >>> what a simplifi

Re: [Zope-dev] zope.component: calling an Interface and calling queryAdapter give differing results

2008-08-29 Thread Dieter Maurer
Chris Withers wrote at 2008-8-29 10:25 +0100: >Dieter Maurer wrote: >> Then, we could get rid of the "{get|query}[Multi]Adapter" altogether >> and consistently use "I()" with appropriate optional parameters -- >> what a simplification and homogenization :-) > >Yeah, but since when has simplific

Re: [Zope-dev] zope.component: calling an Interface and calling queryAdapter give differing results

2008-08-29 Thread Chris Withers
Dieter Maurer wrote: > Jim is heavily defending this difference. > > I am convinced that the difference should not be there fork anyone? ;-) > but meanwhile have found a use case for it. > > Suppose, you have a class "C" that implements "I". > > If "queryAdapter" would behave like "I(...)"

Re: [Zope-dev] zope.component: calling an Interface and calling queryAdapter give differing results

2008-08-29 Thread Chris Withers
Dieter Maurer wrote: > Then, we could get rid of the "{get|query}[Multi]Adapter" altogether > and consistently use "I()" with appropriate optional parameters -- > what a simplification and homogenization :-) Yeah, but since when has simplification or homogenisation been a goal of Zope 3? ;-)

Re: [Zope-dev] zope.component: calling an Interface and calling queryAdapter give differing results

2008-08-23 Thread Dieter Maurer
Jim Fulton wrote at 2008-8-19 17:57 -0400: > >> While I respect that this feature may have been chosen carefully, it >> nevertheless seems more like a misfeature. Chris' expectation was >> reasonable and ought not to be violated without a good cause. > >queryAdapter is used to look up named a

Re: [Zope-dev] zope.component: calling an Interface and calling queryAdapter give differing results

2008-08-23 Thread Dieter Maurer
Chris Withers wrote at 2008-8-19 18:30 +0100: > ... > >>> class ISomething(Interface): pass >... > >>> class MyClass: implements(ISomething) >... > >>> m = MyClass() > >Right, so this does make sense: > > >>> ISomething(m) ><__main__.MyClass instance at 0x00BED6E8> > >This does not: > >>> repr(quer

Re: [Zope-dev] zope.component: calling an Interface and calling queryAdapter give differing results

2008-08-22 Thread Chris Withers
Marius Gedminas wrote: > On Tue, Aug 19, 2008 at 11:19:12PM +0100, Chris Withers wrote: >> However, how should I go about adapting an object to an interface where >> there may or may not be an adapter registered? > > obj = ISomething(otherobj, None) Ah, okay. Now I remember. I've often wanted to

Re: [Zope-dev] zope.component: calling an Interface and calling queryAdapter give differing results

2008-08-22 Thread Chris Withers
Shane Hathaway wrote: >> It sure would be nice if it had a docstring that at least indicated that >> was its only intended purpose. > > Now would be a good time for you to add that docstring to the trunk. :-) Yes well, I apparently don't have enough knowledge to do this correctly. Maybe someone

Re: [Zope-dev] zope.component: calling an Interface and calling queryAdapter give differing results

2008-08-20 Thread Marius Gedminas
On Tue, Aug 19, 2008 at 11:19:12PM +0100, Chris Withers wrote: > However, how should I go about adapting an object to an interface where > there may or may not be an adapter registered? obj = ISomething(otherobj, None) > The natural way would seem to be: > > obj = ISomething(otherobj,default=No

Re: [Zope-dev] zope.component: calling an Interface and calling queryAdapter give differing results

2008-08-19 Thread Shane Hathaway
Chris Withers wrote: > Jim Fulton wrote: No, it's not a bug. This is in fact a feature (like it or not). >>> While I respect that this feature may have been chosen carefully, it >>> nevertheless seems more like a misfeature. Chris' expectation was >>> reasonable and ought not to be violated w

Re: [Zope-dev] zope.component: calling an Interface and calling queryAdapter give differing results

2008-08-19 Thread Chris Withers
Jim Fulton wrote: >>> No, it's not a bug. This is in fact a feature (like it or not). >> While I respect that this feature may have been chosen carefully, it >> nevertheless seems more like a misfeature. Chris' expectation was >> reasonable and ought not to be violated without a good cause. > > q

Re: [Zope-dev] zope.component: calling an Interface and calling queryAdapter give differing results

2008-08-19 Thread Chris Withers
Philipp von Weitershausen wrote: > No, it's not a bug. This is in fact a feature (like it or not). Well, assuming enough people *don't* like it, and I think that's the case here, then it should probably change... > {query|get}Adapter will always try to look up an adapter, whether or not > the

Re: [Zope-dev] zope.component: calling an Interface and calling queryAdapter give differing results

2008-08-19 Thread Jim Fulton
On Aug 19, 2008, at 4:24 PM, Shane Hathaway wrote: > Philipp von Weitershausen wrote: >> Shane Hathaway wrote: >>> Looks like a bug to me. If the object passed as the first >>> argument to >>> queryAdapter() implements the interface passed as the second >>> argument, I >>> believe queryAdapt

Re: [Zope-dev] zope.component: calling an Interface and calling queryAdapter give differing results

2008-08-19 Thread Martin Aspeli
Shane Hathaway wrote: > Philipp von Weitershausen wrote: >> Shane Hathaway wrote: >>> Looks like a bug to me. If the object passed as the first argument to >>> queryAdapter() implements the interface passed as the second argument, I >>> believe queryAdapter() should return the object, regardless

Re: [Zope-dev] zope.component: calling an Interface and calling queryAdapter give differing results

2008-08-19 Thread Shane Hathaway
Philipp von Weitershausen wrote: > Shane Hathaway wrote: >> Looks like a bug to me. If the object passed as the first argument to >> queryAdapter() implements the interface passed as the second argument, I >> believe queryAdapter() should return the object, regardless of any >> component regist

Re: [Zope-dev] zope.component: calling an Interface and calling queryAdapter give differing results

2008-08-19 Thread Philipp von Weitershausen
Shane Hathaway wrote: > Chris Withers wrote: >> From a user's perspective, this makes no sense: >> >> >>> from zope.interface import implements,Interface >> >>> from zope.component import queryAdapter >> >>> class ISomething(Interface): pass >> ... >> >>> class MyClass: implements(ISomething)

Re: [Zope-dev] zope.component: calling an Interface and calling queryAdapter give differing results

2008-08-19 Thread Shane Hathaway
Chris Withers wrote: > From a user's perspective, this makes no sense: > > >>> from zope.interface import implements,Interface > >>> from zope.component import queryAdapter > >>> class ISomething(Interface): pass > ... > >>> class MyClass: implements(ISomething) > ... > >>> m = MyClass() >

[Zope-dev] zope.component: calling an Interface and calling queryAdapter give differing results

2008-08-19 Thread Chris Withers
From a user's perspective, this makes no sense: >>> from zope.interface import implements,Interface >>> from zope.component import queryAdapter >>> class ISomething(Interface): pass ... >>> class MyClass: implements(ISomething) ... >>> m = MyClass() Right, so this does make sense: >>> ISo