workflows.services.executors¶
Built-in workflow step executors registry.
Submodules¶
Classes¶
Approval step executor. |
|
Send an email using either a named template or a simple subject/body. |
|
Registry-backed factory for step executors. |
|
Execute an outbound HTTP call and optionally export values to $vars. |
Package Contents¶
- class workflows.services.executors.ApprovalExecutor[source]¶
Bases:
workflows.services.executors.factory.AbstractStepExecutorApproval step executor.
First encounter (no signal) → AWAITING (AwaitingApproval).
On “reject” → REJECTED (terminal).
- On “approve”:
If this is the last Approval step → APPROVED.
Otherwise → PASSED.
- do_execute(instance, signal)[source]¶
Execute the approval step and return the resulting state.
- Parameters:
instance (workflows.models.WorkflowInstance) – Workflow instance being processed.
signal (str | None) – External decision signal such as
approveorreject.
- Returns:
ExecutorResult describing the new workflow state and step context.
- Return type:
- class workflows.services.executors.EmailExecutor[source]¶
Bases:
workflows.services.executors.factory.AbstractStepExecutorSend an email using either a named template or a simple subject/body.
- do_execute(instance, _signal)[source]¶
Execute the email step.
- Parameters:
instance (workflows.models.WorkflowInstance) – Workflow instance being executed.
_signal (str | None) – Optional signal (unused for email steps).
- Returns:
ExecutorResult describing the outcome of sending the email.
- Return type:
- static _prepare_recipients_and_context(params, instance)[source]¶
Prepare normalized recipients and template context.
- Parameters:
params (dict[str, Any])
instance (workflows.models.WorkflowInstance)
- Return type:
- static _error_result(message, *, outputs=None)[source]¶
Return a standardized FAILED result for this email step.
- Parameters:
message (str) – Human-readable error description.
outputs (dict[str, Any] | None) – Optional additional output fields to include in the context.
- Returns:
ExecutorResult with FAILED state and error details.
- Return type:
- _send_template_email(params, template_key, parts)[source]¶
Handle template-based email sending.
- Parameters:
params (dict[str, Any])
template_key (str)
parts (EmailParts)
- Return type:
- _send_custom_email(params, parts)[source]¶
Handle plain-text email sending.
- Parameters:
params (dict[str, Any])
parts (EmailParts)
- Return type:
- class workflows.services.executors.StepExecutorFactory[source]¶
Registry-backed factory for step executors.
- _registry: ClassVar[dict[str, type[AbstractStepExecutor]]]¶
- classmethod register(step_type, executor_cls)[source]¶
Register an executor class for a step type.
- Parameters:
step_type (str) – Identifier of the step type.
executor_cls (type[AbstractStepExecutor]) – Concrete executor class to instantiate for this type.
- Return type:
None
- class workflows.services.executors.WebhookExecutor[source]¶
Bases:
workflows.services.executors.factory.AbstractStepExecutorExecute an outbound HTTP call and optionally export values to $vars.
URL, headers, and string body templating with Django templates using a ‘ctx’ dict
Supports method, headers, body, auth (basic|bearer), timeoutSecs
result_to/result_source for whole-response capture
fine-grained exports: [{“from_path”:”json.foo”,”to_path”:”serial”}] # note: bare key allowed
Stores per-step context and returns a flat vars map for $vars merging.
- to_path:
Accepts either “serial” or “vars.serial” (we strip optional “vars.” and store under $vars).
- do_execute(instance, _signal)[source]¶
Execute the webhook step.
- Parameters:
instance (workflows.models.WorkflowInstance) – Workflow instance being executed.
_signal (str | None) – Optional signal (unused for webhook steps).
- Returns:
ExecutorResult describing step outcome and exported vars.
- Return type: