loom.rest.autocrud¶
Auto-CRUD route and UseCase generators.
Generates concrete UseCase subclasses and
RestRoute objects for the five standard CRUD operations,
given a domain model type.
The generated classes are cached per model — multiple interfaces sharing the same model reuse the same UseCase classes.
NOTE: This module intentionally omits from __future__ import annotations so
that annotation expressions are evaluated eagerly at class-definition time.
The factory functions capture model as a closure variable and embed it
directly in the execute signature, making typing.get_type_hints work
without requiring the model name to be present in the module’s global namespace.
Usage:
from loom.rest.autocrud import build_auto_routes
routes = build_auto_routes(User, include=("create", "get", "list"))
Functions
|
Derive a |
|
Derive a |
|
Build a |
|
Return cached (or freshly built) UseCase classes for all five operations. |
|
Return the declared |
|
Return |
|
Generate a UseCase that creates a new entity via the main repository. |
|
Generate a UseCase that deletes an entity by id. |
|
Generate a UseCase that fetches a single entity by id. |
|
Generate a UseCase that lists entities via a QuerySpec. |
|
Generate a UseCase that applies a partial update to an entity. |
|
Return field names that are server-assigned and must not appear in write inputs. |
|
Return |
- loom.rest.autocrud.build_auto_routes(model, include)[source]¶
Return
RestRouteobjects for the requested CRUD operations.Lazily imports
RestRouteto avoid circular imports at module load time.- Parameters:
- Returns:
Tuple of
RestRouteinstances, one per requested operation.- Return type:
Example:
routes = build_auto_routes(User, include=("create", "get", "list"))