[Zope] Re: help with __bobo_traverse__

yuppie y.2004_ at wcm-solutions.de
Fri May 28 04:30:20 EDT 2004


Hi!


Mohamed Lrhazi wrote:
> def __before_publishing_traverse__(self, obj, req):
>     """
>     """
>     stack = req['TraversalRequestNameStack']
>     stack.reverse()

I doubt you want to do that. 'stack' is not a copy. So if your condition 
is not true, TraversalRequestNameStack is screwed up.

>     if len(stack) and stack[0] == 'dview':
>         # stop looking for next obj to publish by emptying stack
>         req['TraversalRequestNameStack'] = []
>         req['YSURLARGS'] = stack[:]

Something like that should be better:

     def __before_publishing_traverse__(self, obj, req):
         """
         """
         stack = req['TraversalRequestNameStack']
         if stack and stack[-1] == 'dview':
             # stop looking for next obj to publish by emptying stack
             stack.reverse()
             req['TraversalRequestNameStack'] = []
             req['YSURLARGS'] = stack[:]


BTW: Why can't you simply use traverse_subpath?


Cheers,
	Yuppie




More information about the Zope mailing list