[Zope3-dev] traversing path from scratch

Shane Hathaway shane@zope.com
Tue, 07 May 2002 12:03:42 -0400


Steve Alexander wrote:
> The Traverser is the only application-level thing that needs to directly 
> know about the Root object.
> 
> I don't like the look of this:
> 
>   return getAdapter(None, ITraverser).traverse(self.subscriber_path)
> 
> Adapting from None doesn't make sense to me, from a 
> code-that-reflects-your-intentions point of view.
> 
> I think we need a Traversal service. The Traversal service will get you 
> an ITraverser, just as in the getAdapter call above. The Traversal 
> service knows about the root object, so it can provide traversal in the 
> absence of a wrapped object to start from.
> 
> 
> (I'm assuming here that there's only supposed to be a single root object 
> for a zope instance. If there are several root objects, then I guess 
> that each root object will offer its own placeful traversal service, and 
> there will need to be another means of getting the root objects. Someone 
> say yagni please!)

yagni. ;-)  Having only one root is easier to think about.  We've never 
had any reason to have more than one.

Traversal as a service makes sense, I think.  It might also be a 
utility.  When I want to choose between utilities and services, I use a 
house metaphor.  I think of whether the functionality should be more 
like a chair (portable, but not always around) or a water faucet (always 
around, but not portable).  Traversal should always be there and no one 
should need to move it around, so it's more like a service.

Shane