[Zope3-dev] Re: Providing flexible adapters

Shane Hathaway shane@zope.com
Tue, 26 Feb 2002 12:51:06 -0500


Steve Alexander wrote:
> Steve Alexander wrote:
> 
>>
>> I don't see how a utility helps here. The utility needs to be 
>> "acquired" from the context of the object, not from the context of the 
>> component that wants to get the object's reference.
>>
>> Surely an adapter can do that task. 
> 
> Or rather, an adapter's "maker", that is, factory.

Ok, but then you'd need some kind of special registry so that the 
factory can choose what kind of reference to create based on the place 
of the object.  You would want it to be a managed registry so you can 
configure it.  Services are the right way to create managed registries, 
so you'll need a service.  The adapter factory will essentially defer to 
a service.

I think the correct choice of reference type depends more on its place 
than the type of the object it points to (except perhaps outside Zope). 
  The simplest kind of reference just stores the object as an attribute 
of self.  That kind of reference will work for all object types, but not 
for objects that expect an environment via wrappers.  So again, the 
choice depends more on the object's environment than the type of the object.

That's why I think a utility is more appropriate.  You could certainly 
do the same thing with an adapter factory, but that's stretching the 
concept of adapters.  This is just an academic discussion, though, and I 
need to work on useful stuff.  Thanks for the brain exercise. :-)

Shane