[Grok-dev] Traversing
Martijn Faassen
faassen at infrae.com
Fri Oct 20 04:12:09 EDT 2006
Christian Theune wrote:
> I just noticed that our traverser does not know what to do if traverse()
> isn't defined.
>
> I stumbled over that when I switched our wiki to grok.Container. I
> talked to Philipp shortly on IRC and he proposed not to do fallback to
> attribute/dict access.
>
> I somewhat agree. However, we have to define how grok.Container behaves.
>
> The most simple solution I can imagine would be to define a default
> traverse() on the container that does the dict lookup.
I'm not sure what you are proposing as the behavior.
What I expect traverse to do:
if not on a container, return the object I want to traverse to, or None
if there's no object to traverse to, in which case the end-user should
see a 404.
if on a container, I want to define the object I want to traverse to, or
None if there's no object to traverse to. In that case, the container
falls back on its normal traversal behavior and tries to traverse into
itself.
if traverse isn't defined, then Containers will behave as they do
normally, so allow traversal into their contents.
Since inside the container traverse() I can inspect the contents of the
container, this allows me to do anything I want - either traverse into
my own traversal space, or the container's if there's something
available, or neither.
Regards,
Martijn
More information about the Grok-dev
mailing list