Emulating traverse_subpath in a Z3 view in Zope 2.10
Related / Source: http://grok.zope.org/documentation/how-to/traversing-subpaths-in-views
This article is about creating a Zope 3 view that emulates the Zope 2 PythonScript "traverse_subpath" behavior, that of passing in extra parameters to a view using path segments rather than query parameters. The most useful place I can see this being used is to specify a date (like in the article referenced above).
First, read the referenced article. This article illustrates how to do this using a Grok View in Zope 3. The procedure for Z3 views in Zope 2 is very similar, but a few "slight" modifications are required to get it working in Zope 2.10.
- The view needs to implement
- zope.publisher.interfaces.IPublishTraverse
- . Apparrently Grok Views do this automatically.
- In the publishTraverse method, use request['TraversalRequestNameStack'] rather than the convenience methods request.getTraversalStack() and request.setTraversalStack()
With these two modifications to the recipe, you've got a Zope 3 view in Zope 2 with positional arguments taken from the sub-path.