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 icky.

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

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 to

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 Python

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() seems more

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 this. How

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

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 signature as you

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 :-) I don't

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 the

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 =

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 (which is

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

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 simplification and

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 adapt.

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 of

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 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 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 langs =

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? ;-) Chris

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(...), you would

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 simplification or

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(queryAdapter(m,ISomething)) 'None'

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 adapters.

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 with

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 be

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=None)

[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: ISomething(m)

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) ... m = MyClass()

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 registrations.

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 of any

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 queryAdapter() should

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 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.

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 without a good