[Zope3-dev] Custom Object Traverser

Steve Alexander steve@cat-box.net
Wed, 09 Apr 2003 09:31:42 +0200


Stephan Richter wrote:
> Hello,
> 
> it is me one more time. I would like to register a custom object traverser 
> (independent of presentation type) for an object. How do I write it and how 
> do I register it via ZCML?
> 
> Right now I am using a browser only Traverser for Wiki Pages, but this is 
> certainly not a permanent solution.

Look at zope/app/container/traversal.py

The ContainerTraverser is for use with the Browser publisher. You have 
something like this already. As you've found out, you use it only for 
saying how traversal works when the object is published in a browser.

The ContainerTraversable is for general traversal, including use from 
page templates, and use from the convenience functions in 
zope.app.traversing such as traverse and traverseName.

So, you need to implement an ITraversable adapter for your object. The 
adapter will be used to decide how to traverse the next step, starting 
from your object.

--
Steve Alexander