core.prototypes.skelmodule
¶
Module Contents¶
Classes¶
This is the extended module prototype used by any other ViUR module prototype. |
Functions¶
Loads all indexes from the index.yaml and stores it in a dictionary sorted by the module(kind) |
Attributes¶
Type for exactly one sort order definitions. |
|
Type for sort order definitions (any amount of single order definitions). |
|
Type for default sort order definitions. |
|
Defines the header parameter that might contain a client-defined bone list. |
- core.prototypes.skelmodule.SINGLE_ORDER_TYPE¶
Type for exactly one sort order definitions.
- core.prototypes.skelmodule.ORDER_TYPE¶
Type for sort order definitions (any amount of single order definitions).
- core.prototypes.skelmodule.DEFAULT_ORDER_TYPE¶
Type for default sort order definitions.
- core.prototypes.skelmodule.__load_indexes_from_file()¶
Loads all indexes from the index.yaml and stores it in a dictionary sorted by the module(kind) :return A dictionary of indexes per module
- Return type:
dict[str, list]
- core.prototypes.skelmodule.DATASTORE_INDEXES¶
- core.prototypes.skelmodule.X_VIUR_BONELIST: Final[str] = 'X-VIUR-BONELIST'¶
Defines the header parameter that might contain a client-defined bone list.
- class core.prototypes.skelmodule.SkelModule(*args, **kwargs)¶
Bases:
viur.core.Module
This is the extended module prototype used by any other ViUR module prototype. It a prototype which generally is bound to some database model abstracted by the ViUR skeleton system.
- kindName: str¶
Name of the datastore kind that is handled by this module.
This information is used to bind a specific
viur.core.skeleton.Skeleton
-class to this prototype. By default, it is automatically determined from the module’s class name, so a module named Animal refers to a Skeleton named AnimalSkel and its kindName is animal.For more information, refer to the function
_resolveSkelCls()
.
- default_order: DEFAULT_ORDER_TYPE¶
Allows to specify a default order for this module, which is applied when no other order is specified.
Setting a default_order might result in the requirement of additional indexes, which are being raised and must be specified.
- _resolveSkelCls(*args, **kwargs)¶
Retrieve the generally associated
viur.core.skeleton.Skeleton
that is used by the application.This is either be defined by the member variable kindName or by a Skeleton named like the application class in lower-case order.
If this behavior is not wanted, it can be definitely overridden by defining module-specific
viewSkel()
,addSkel()
, oreditSkel()
functions, or by overriding this function in general.- Returns:
Returns a Skeleton class that matches the application.
- Return type:
Type[viur.core.skeleton.Skeleton]
- baseSkel(*args, **kwargs)¶
Returns an instance of an unmodified base skeleton for this module.
This function should only be used in cases where a full, unmodified skeleton of the module is required, e.g. for administrative or maintenance purposes.
By default, baseSkel is used by
viewSkel()
,addSkel()
, andeditSkel()
.- Return type:
viur.core.skeleton.SkeletonInstance
- skel(*, allow_client_defined=False, bones=(), exclude_bones=(), **kwargs)¶
Retrieve module-specific skeleton, optionally as subskel.
- Parameters:
allow_client_defined (bool) – Evaluates header X-VIUR-BONELIST to contain a comma-separated list of bones. Using this parameter enforces that the Skeleton class has a subskel named “*” for required bones that must exist.
bones (tuple[str, Ellipsis] | List[str]) – Allows to specify a list of bones to form a subskel.
exclude_bones (tuple[str, Ellipsis] | List[str]) – Provide a list of bones which are always excluded.
- Return type:
viur.core.skeleton.SkeletonInstance
The parameters bones and allow_client_defined can be combined.
- _apply_default_order(query)¶
Apply the setting from default_order to a given db.Query.
The default_order will only be applied when the query has no other order, or is on a multquery.
- Parameters:
query (viur.core.db.Query) –
- add_or_edit(key, **kwargs)¶
This function is intended to be used by importers. Only “root”-users are allowed to use it.
- Parameters:
key (viur.core.db.Key | int | str) –
- Return type:
Any