[Zope3-dev] Re: Providing flexible adapters
Shane Hathaway
shane@zope.com
Tue, 26 Feb 2002 13:14:13 -0500
Steve Alexander wrote:
> Shane Hathaway wrote:
>
>> 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.
>
>
> Can't it just walk up the ContextWrapper of the object, and get the
> nearest utility that's willing to provide an IReference ?
>
> That's what I originally proposed.
But I think that would mean the configuration would vary in a lot of
places. You wouldn't want to have to provide an Adapter service for
every Principal object, for example, even though you might need a
different IReference for things contained in principals than for things
contained in principal folders.
Using a utility neatly wraps up the whole policy of reference generation
into a single place so we can figure out what the right thing is later.
>> That's why I think a utility is more appropriate.
>
>
> I agree, sort of ;-)
> The utility needs to be in the context of the object, not in the context
> of the thing that wants a reference of the object.
We always agreed on that. :-)
Shane