[Zope3-dev] object arg overloaded in IAdapterService.getAdapter
Steve Alexander
steve@cat-box.net
Tue, 26 Feb 2002 19:28:16 +0000
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