In the example above, myapp.traversal.Traverser is assumed to be a class that implements the following interface:
1 class Traverser(object):
2def __init__(self, root):
3""" Accept the root object returned from the root factory """
4
5def __call__(self, request):
6""" Return a dictionary with (at least) the keys ‘‘root‘‘,
7‘‘context‘‘, ‘‘view_name‘‘, ‘‘subpath‘‘, ‘‘traversed‘‘,
8 |
‘‘virtual_root‘‘, and ‘‘virtual_root_path‘‘. These values are |
9typically the result of a resource tree traversal. ‘‘root‘‘
10is the physical root object, ‘‘context‘‘ will be a resource
11object, ‘‘view_name‘‘ will be the view name used (a Unicode
12name), ‘‘subpath‘‘ will be a sequence of Unicode names that
13followed the view name but were not traversed, ‘‘traversed‘‘
14will be a sequence of Unicode names that were traversed
15(including the virtual root path, if any) ‘‘virtual_root‘‘
16will be a resource object representing the virtual root (or the
17physical root if traversal was not performed), and
18‘‘virtual_root_path‘‘ will be a sequence representing the
19virtual root path (a sequence of Unicode names) or None if
20traversal was not performed.
21
22Extra keys for special purpose functionality can be added as
23necessary.
24
25All values returned in the dictionary will be made available
26as attributes of the ‘‘request‘‘ object.
27"""
More than one traversal algorithm can be active at the same time. For instance, if your root factory returns more than one type of object conditionally, you could claim that an alternate traverser adapter is “for” only