[Zope3-dev] Re: Providing flexible adapters

Steve Alexander steve@cat-box.net
Tue, 26 Feb 2002 17:28:25 +0000


Shane Hathaway wrote:
> Steve Alexander wrote:
> 
>> Sounds like one to me... Here's an object. Give me an appropriate 
>> IReference.
>>
>> What could we possibly want to do under the hood that an adapter would 
>> be incapable of, but a utility would be capable of?
>
> Let's say we provide a ReferenceByPath adapter for all IFolder objects. 
>  This is the normal case in Zope 2.  Then let's say we put a simple 
> folder inside a placeful service.  Services can't be looked up by simple 
> paths, so I guess we have to augment the contract of ReferenceByPath. 
> Then let's say we put a simple folder inside a placeful user object (for 
> storing preferences).  Users don't get looked up by simple paths either, 
> so again we have to augment the contract of ReferenceByPath.  Then we 
> want to refer to a simple folder accessible only via SOAP.  Wow.
> 
> In the end we have ReferenceByAnyPossiblePathOrURL, and we have followed 
> the course of Zope 2.  We should have made it configurable.  We should 
> have been able to make different kinds of references without modifying 
> existing software.
> 
> We could use an URL protocol registry as Phillip suggested, but what 
> happened to the very simple contract ReferenceByPath had?  What about 
> ReferenceByOID?
> 
> You see, I don't think we can yet define all the axes that modify the 
> choice of reference type.  Not even the object itself can adequately 
> define how to make a reference to itself.  Utilities are meant to solve 
> this class of problem.


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.

--
Steve Alexander