Capabilities / Relation Lookup
InMemoryRelationLookupCapability
- class teksi_hooks.capabilities.relation_lookup.InMemoryRelationLookupCapability(objects=<factory>)[source]
In-memory relation lookup implementation.
This implementation is intended for tests, examples and small offline scenarios.
All objects live in one object pool. This is important for recursive relation traversal, because an object found as the related object in one hop may become the local object in the next hop.
Example:
- reach_point
- -> reach
-> wastewater_structure
In this chain, reach is first a related object, then a local object.
- Parameters:
objects (tuple[CanonicalObject, ...])
- classmethod from_sides(*, local_objects=(), related_objects=())[source]
Convenience constructor for tests that want to express local and related sides explicitly.
The resulting lookup still uses one combined object pool so recursive relation traversal works correctly.
- Parameters:
local_objects (Sequence[CanonicalObject])
related_objects (Sequence[CanonicalObject])
- Return type:
- canonical_objects(*, local_class_id, related_class_id, local_attribute, related_attribute, value)[source]
Return related object identities matching the configured join.
The local side must exist in the in-memory object pool. If no local object matches the supplied local class and local attribute value, no related objects are returned.
- Parameters:
local_class_id (str)
related_class_id (str)
local_attribute (str)
related_attribute (str)
value (Any)
- Return type:
Sequence[CanonicalObjectIdentity]
- current_object(identity)[source]
Return the current canonical object or None if it no longer exists.
- Parameters:
identity (CanonicalObjectIdentity)
- Return type:
CanonicalObject | None
Base class: RelationLookupCapability
Fields
objectsType:
tuple[CanonicalObject, ...]Canonical objects available for lookup.