Transition#
This module defines a transition class that is used to specify conditions and destinations for transitions to nodes.
- class Transition(*, cnd=True, dst, priority=None)[source]#
Bases:
BaseModel
A basic class for a transition to a node.
- cnd: AnyCondition#
A condition that determines if transition is allowed to happen.
- dst: AnyDestination#
Destination node of the transition.
- priority: AnyPriority#
Priority of the transition. Higher priority transitions are resolved first.
- async get_next_label(ctx, transitions, default_priority)[source]#
Determine the next node based on
transitions
andctx
.The process is as follows:
Condition result is calculated for every transition.
Transitions are filtered by the calculated condition.
Priority result is calculated for every transition that is left.
default_priority
is used for priorities that returnTrue
orNone
as perBasePriority
. Those that returnFalse
are filtered out.Destination result is calculated for every transition that is left.
The highest priority transition is chosen. If there are multiple transition of the higher priority, choose the first one of that priority in the
transitions
list. Order oftransitions
is as follows:node transitions, local transitions, global transitions
.
If at any point any
BaseCondition
,BaseDestination
orBasePriority
produces an exception, the corresponding transition is filtered out.- Return type:
Optional
[AbsoluteNodeLabel
]- Returns:
Label of the next node or
None
if no transition is left by the end of the process.