5.3 · Reference
Generated CRUD API¶
The CRUD guide explains action generation, access policies, ownership, schema requirements and route replacement.
hinoki.resources.crud ¶
crud(
model: type[Model],
*,
path: str,
read: type[Schema],
create: type[Schema] | None = None,
update: type[Schema] | None = None,
delete: bool = False,
access: Access | CrudAccess | None = None,
public_writes: bool = False,
owner: str = "",
identity_key: Callable[[Any], Any] = attrgetter("id"),
assign: Mapping[str, Callable[[Any], Any]]
| None = None,
pagination: PageNumberPagination = PageNumberPagination(),
omit: tuple[str, ...] = (),
) -> CrudDeclaration
Declare generated CRUD for model.
app.include(crud(...)) mounts the generated actions; @crud(...) on a
class adds the hooks (get_queryset, to_schema, written_queryset,
store, change, remove) and handwritten actions.
A single Access protects every action; CrudAccess sets them apart.
hinoki.resources.CrudAccess
dataclass
¶
Per-action access for crud(access=...).
An action without its own entry uses default; None means public.
hinoki.resources.CrudDeclaration ¶
What crud(...) returns: include it for plain CRUD, or apply it to a
class that adds hooks and handwritten actions.
generated
instance-attribute
¶
generated = [
name
for name in ACTIONS
if name not in config.omit and enabled(config, name)
]
hinoki.resources.Crud ¶
Bases: StrEnum
The generated actions replaces= can name (each is also its plain string).