websauna.system.core.traversal module

Traversing core logic.

class websauna.system.core.traversal.Resource(request)[source]

Bases: object

Traversable resource in a nested tree hierarchy with basic breadcrumbs support.

All traverable context classes should inherit from this class. Note that this is not a strict requirement, as often anything implementing pyramid.interfaces.ILocation and get_title() will work.

For more information see Traversal.


Return human-readable title of this resource.

This is viewed in admin breadcrumbs path, etc.

Return type


classmethod make_lineage(parent, child, name, allow_new_parent=False)[source]

Set traversing pointers between the child and the parent resources.

Builds __parent__ and __name__ pointer and sets it on the child resource.

  • If lineage relationship is not lazy and the referenced children is stored in the parent, the lineage must be set when the child is put into parent container.

  • If lineage relationship is lazy and child resource is constructed upon lookup in __item__, the lineage is constructed before the child is returned.

  • parent – Parent resource who children is become part to

  • child – Child resource mutated in place

  • name – Id of the child resource as it will appear in the URL traversing path

  • allow_new_parent – If the child has alraedy a parent assigned, allow override the parent… or basically move an existing resource. You don’t usually want this for in-memory resource and this is for catching bugs.

Return type



The mutated child resource