[Zope3-dev] Re: object arg overloaded in IAdapterService.getAdapter
Jim Fulton
jim@zope.com
Tue, 26 Feb 2002 17:54:09 -0500
I agree that there should be an optional place to look up the
adapter as an alternate to the place of the adapted object.
In fact, I remember deciding this a long time ago although it
might have been for views. I even wrote it down. Now, where
was that .... ;)
Please feel free to add this or to add a task to the collector.
Jim
Steve Alexander wrote:
>
> In the IAdapterService interface, the object argument is overloaded with
> two meanings.
>
> def getAdapter(object, interface, default=None):
> """Look up an adapter that provides an interface for an object
>
> The object also provides a place to look for placeful adapters.
>
> A Zope.ComponentArchitecture.ComponentLookupError will be
> raised if the component can't be found.
> """
>
> I would like to have the meanings separated out into:
>
> * the place to look for placeful adapters
>
> * the interfaces to adapt from
>
> Here's why:
>
> Take the example of an IContact object that I want to get city/state
> information for.
>
> Let's say there are two placeful adapter-makers for this:
>
> 1: a free service that has low quality information
>
> 2: a paid-for service that is backed by a large up-to-date database
>
> The service that I get to use should depend on the context of the caller
> of getAdapter, not on the context of the IContact object I'm adapting.
>
> To do this, we need to have the option of not overloading the "object"
> argument in getAdapter, and instead have two arguments: placeful_context
> and object_to_adapt. (rename as needed.)
>
> Until about 10 minutes ago, I had thought that adapters were placeful in
> the caller's context. Of course, I hadn't really thought about it...
> that's how Zope 2's ubiquitous acquisition can poison one's mind ;-)
>
> --
> Steve Alexander
--
Jim Fulton mailto:jim@zope.com Python Powered!
CTO (888) 344-4332 http://www.python.org
Zope Corporation http://www.zope.com http://www.zope.org