vibe.handlers.computable¶
Handler for Computable Variables.
Implements the DataTypeHandler interface for computable variables that derive their values through either inline Python expressions or function calls. Supports both simple expressions for basic calculations and function-based computations for complex logic with full IDE support and debugging capabilities.
Examples:
Inline expression¶
tax_amount: type: computable compute: "base_price * tax_rate / 100"
Function-based computation¶
total_price: type: computable compute_function: "calculate_total"
ValidatedComputable ¶
ValidatedValue for computable variables during static analysis.
__init__ ¶
__init__(value: object, variable_name: str, definition: dict[str, Any], reporter: Callable[[Any], None]) -> None
Initialize with either compute expression or compute_function reference.
ComputableHandler ¶
Handler for computable variables with expression or function-based computation.
__init__ ¶
__init__(definition: dict[str, Any]) -> None
Initialize with validated 'compute' expression or 'compute_function' reference.
compute_value ¶
compute_value(context: NestedValue, template_data: TemplateData | None = None) -> object
Compute the value using either expression or function.
| Parameters: |
|
|---|
| Returns: |
|
|---|
| Raises: |
|
|---|
render_widget ¶
render_widget(name: str, current_value: object, error_message: str | None = None) -> str
Return empty string - computable variables don't render UI widgets.
process_form_data ¶
process_form_data(name: str, form_data: MultiDictLike) -> None
Return None - computable variables don't process form data.
validate_input ¶
validate_input(value: object, check_required: bool = True) -> str | None
Return None - computable variables don't need input validation.
get_preview_placeholder_value ¶
get_preview_placeholder_value() -> str
Return a user-friendly placeholder for preview when not yet computed.