This module contains Kotti’s node tree traverser.
In Kotti versions < 1.3.0, Pyramid’s default traverser
pyramid.traversal.ResourceTreeTraverser) was used. This traverser
still works, but it becomes decreasingly performant the deeper your resource
tree is nested. This is caused by the fact, that it generates one DB query per
level, whereas the Kotti traverser (
generates a single DB query, regardless of the number of request path segments.
This query not only finds the context, but also returns all node items in its
lineage. This means, that neither accessing
context.parent nor calling
pyramid.location.lineage() will result in additional DB queries.
The performance benefits are huge. The table below compares the requests per
seconds (rps) that were reached on a developer’s notebook against a PostgreSQL
database with 4419
|request.path||Pyramid traverser (rps)||Kotti traverser (rps)|
An optimized resource tree traverser for
kotti.resources.Nodebased resource trees.
- root (
kotti.resources.Node) – The node where traversal should start
- vpath_tuple (tuple) – Tuple of path segments to be traversed
List of nodes, from root (excluded) to context (included). Each node has its parent set already, so that no subsequent queries will be be performed, e.g. when calling
- root (