[Zope-dev] Specialists and __bobo_traverse__
Roch'e Compaan
roche@ybm.co.za
Mon, 15 Jan 2001 14:41:58 +0200
Recent sightings of the use of __bobo_traverse__ in SkinScript gave me hope
of giving users a more useable breadcrumbs trail in the case where I have
nested specialists.
My TaskTemplates specialist is nested inside my RequestTypes specialist.
When I retrieve a dataskin from the RequestTypes specialist I have a tab
that lists TaskTemplates for that RequestType specialist. Following a link
from the TaskTemplate list takes you to that instance.
Thus results in a url like this:
/RequestTypes/<request type instance>/Task Templates/<task template
instance>,
and what I ideally want is:
/RequestTypes/<request type instance>/<task template instance>.
I read all the comments about __bobo_traverse__ and created a python method,
"traversal_method" inside the "RequestTypes" specialists. I must admit that
I don't really understand Zope's traversal machinery yet and would
appreciate some guidance.
My SkinScript for RequestTypes:
WITH SELF COMPUTE __bobo_traverse_=traversal_method
My traversal_method:
ob = getattr(self, name)
if ob is not None:
return ob
else:
ob = self.TaskTemplates.getItem(name)
if ob is not None:
return ob
raise 'NotFound'
Any help would be greatly appreciated.
Roché