[Zope] How to get REST friendly urls from sql database

Gaute Amundsen gaute at div.org
Wed Feb 21 06:32:30 EST 2007


On Tuesday 20 February 2007 17:39, Paul Winkler wrote:
<snip>
> Another option is that the object at /articles could be an instance
> of a class that looks something like:
>
> class MyArticleContainer():
>
>     def __before_publishing_traverse__(self, unused, request):
>         # Save the rest of the path as 'traverse_subpath'.
>         request.set('traverse_subpath',
>                     reversed(request['TraversalRequestNameStack']))
>         # Tell the publisher to stop traversing now.
>         request['TraversalRequestNameStack'][:] = []
>
>     def __call__(self, *args, **kw):
>         subpath = self.REQUEST['traverse_subpath']
>         data = get_data_however_you_like(subpath)
>         return data
>
>
> For background, read the stuff about traversal hooks at
> http://wiki.zope.org/zope2/ZPublisher


Hm.. that looks more like what I had in mind when I posted, but allso quite a 
bit more overhead than rewriterules.
At least for me that has never written a product.

I will have to think about that one..
Would you care to elaborate a little bit on what the tradeoffs would be?

If I wanted my articles in many variants, ie. a large state space, I guess 
this way would be good?

Gaute




More information about the Zope mailing list