vibe.web.utils¶
Shared utility functions for the web routing layer.
InvalidSessionException ¶
Custom exception for sessions being mismatched with the currently requested template, or otherwise invalid.
TemplateLoadError ¶
Custom exception for errors during template loading in routes.
| Attributes: |
|
|---|
make_unauthorized_response ¶
make_unauthorized_response(reason: str) -> Response
Return a 401 response with detail only when debug mode is active.
In production, clients see a generic "Unauthorized" body so that error messages don't leak implementation details. In debug mode the full reason string is returned together with a synthetic stack trace to make it easy to locate the call site.
get_session_template_data ¶
get_session_template_data(template_id_expected: str, version_id_expected: str | None, validate_session: bool = True) -> TemplateData
Fetch template data for the expected template/version, and optionally validate session.
| Parameters: |
|
|---|
| Returns: |
|
|---|
| Raises: |
|
|---|
extract_condition_string ¶
extract_condition_string(source_lines: list[str], condition_lineno: int) -> str | None
Extract the Jinja expression from an {% if/elif/for ... %} tag.
| Parameters: |
|
|---|
| Returns: |
|
|---|
resolve_template_and_local_path ¶
resolve_template_and_local_path(template_data: TemplateData, question_path: str) -> tuple[TemplateData, str]
Resolve which template a namespaced question belongs to.
| Parameters: |
|
|---|
| Returns: |
|
|---|
handle_route_exception ¶
handle_route_exception(e: Exception, template_id_for_error_display: str, version_for_error_display: str, is_htmx_request: bool, is_eventstream: bool) -> Response
Handle common exception scenarios for routes, log the error, and prepare an appropriate Flask response.
| Parameters: |
|
|---|
| Returns: |
|
|---|
get_complete_question_definitions ¶
get_complete_question_definitions(host_template_data: TemplateData) -> dict[str, Any]
Create an augmented dictionary of block definitions including all component questions.
| Parameters: |
|
|---|
| Returns: |
|
|---|