[Zope-dev] ZPatterns sub-Specialist traversal
Michael R. Bernstein
webmaven@lvcm.com
Mon, 09 Apr 2001 17:44:07 -0700
With some help from the kind folks on #zope, this has been
solved.
"Michael R. Bernstein" wrote:
>
> Here is what I've done:
>
> ArchiveImages (Specialist)
> defaultRack
> traversal_method (Python Script)
> traversal (SkinScript)
> Renderings (sub-Specialist)
> defaultRack
This was wrong in a couple of ways, here is how it needs to
be layed out:
ArchiveImages (Specialist)
traversal_method (Python Script)
defaultRack
traversal (SkinScript)
Renderings (sub-Specialist)
defaultRack
As you can see, the Python Method needed to be moved from
within the Rack up into the Specialist.
> traversal_method has 'REQUEST, name' as parameters, and the
> following body:
>
> return getattr(container.Renderings, name)
The body of the traversal_method needed to change in two
ways:
if name in ['index_html', 'editInstanceForm',
'editInstance']:
return getattr(context, name)
else:
return container.Renderings.getItem(name)
First, it needed to pass unmolested those methods of the
ArchiveImage that were needed. Second, Specialists
apparently don't support getattr(), so I needed to change
this to call getItem() instead.
> The 'traversal' SkinScript has the following body:
>
> WITH SELF COMPUTE __bobo_traverse__=traversal_method
The SkinScript works fine as-is.
HTH,
Michael Bernstein.