[Zope3-dev] Re: Providing flexible adapters

Shane Hathaway shane@zope.com
Tue, 26 Feb 2002 17:41:21 -0500


Jim Fulton 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.  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).
>>
> 
> This sounds pretty complex to me.  I can't even follow your original
> example:
> 
> "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."
> 
> Wow indeed. I don't even know what you said. ;)
> 
> This feels like complicated architecture to supprt some kind of edge
> case.

It is.  That was a counterexample. :-)

My position is that we should just have simple reference objects.  If 
application code wants to make a reference to an arbitrary object but 
doesn't know what kind of reference to create, it should ask an 
IReferenceGenerator utility to make one.  The utility would probably do 
something simple to make it, but if we need more complexity someday, we 
have a place to add it.  That's all there is to it. :-)

Shane