Hi all I try to use traverse_subpath in my product but I can't found a real good solution I found some pages explaining you need to override __bobo_traverse__ or __getitem__ in order to implement traverse_subpath on a product but I think it's a really poor solution My question could be: Is there any simple solution to implement traverse_subpath on my product? TIA
Garito wrote:
I try to use traverse_subpath in my product but I can't found a real good solution I found some pages explaining you need to override __bobo_traverse__ or __getitem__ in order to implement traverse_subpath on a product but I think it's a really poor solution
My question could be:
Is there any simple solution to implement traverse_subpath on my product?
What do you mean by "implement" and "product" in this context? In Python Scripts and Page Templates traverse_subpath is available as variable. There is nothing to implement if you use one of them. Cheers, Yuppie
Garito wrote:
I try to use traverse_subpath in my product but I can't found a real good solution I found some pages explaining you need to override __bobo_traverse__ or __getitem__ in order to implement traverse_subpath on a product but I think it's a really poor solution
Much better is to define a __before_publishing_traverse__ method on your object. Unfortunately, due to a longstanding bug in the hook machinery, you will need to write your method like this for the moment: def __before_publishing_traverse__(self, x, request=None): if request is None: request = x # Use self and request normally from here. Inside your hook method, you can examine and manipulate the stack of un-traversed path names "request['TraversalRequestNameStack']". Cheers, Evan @ 4-am
Evan Simpson wrote:
Much better is to define a __before_publishing_traverse__ method on your object. Unfortunately, due to a longstanding bug in the hook machinery,
Is there a collector entry for this? What's the bug? Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
Chris Withers wrote:
Evan Simpson wrote:
Much better is to define a __before_publishing_traverse__ method on your object. Unfortunately, due to a longstanding bug in the hook machinery,
Is there a collector entry for this? What's the bug?
I was certain that there was a collector entry related to this, but I can't find it for the life of me. The bug is in MultiHook, and affects only classes that define a __before_publishing_traverse__ method. Normally, the method would be called with arguments (container, request) after being bound to the instance. MultiHook was carefully calling the underlying unbound function instead. Thus, if your method signature was (self, container, request), it would be called correctly until something else tried to use the hook (such as a VHM or Access Rule). I've checked in a fix for the 2.7 branch, but I haven't set up Subversion yet, so I haven't fixed the HEAD. Cheers, Evan @ 4-am
Evan Simpson wrote:
I've checked in a fix for the 2.7 branch, but I haven't set up Subversion yet, so I haven't fixed the HEAD.
Can you submit a collector entry as a reminder to do this then? :-) thanks, Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
participants (4)
-
Chris Withers -
Evan Simpson -
Garito -
yuppie