[Zope] Hooking into traversal
Michel Pelletier
michel@digicool.com
Fri, 03 Mar 2000 16:48:19 -0800
"Andrew M. Kuchling" wrote:
>
> I want to write an object that can be traversed by ZPublisher. The
> goal is so I can write URLs like thingyForwarder/45/display, to get an
> object corresponding to thingy #45, and call its display() method.
>
> What's the Zope Zen way of doing this? Implement an __of__ method for
> acquisition? Implement a __bobo_traverse__ method? Make
> thingyForwarder a Folderish object and implement all the folder
> methods?
Take yer pick.
ZPublisher will try the following methods to traverse an object, in this
order:
__bobo_traverse__(request, name)
Request is, suprise, the REQUEST object, and 'name' is the path
element ZPublisher is trying to traverse to.
getattr
ZPublisher will try and get the subobject by 'name' with getattr. If
this fails with an Attribute error then...
getitem
ZPublisher will try to get the subobject by 'name' with getitem. If
this fails, you get a 404.
-Michel