core.skeleton.utils¶
Classes¶
A typed list of |
Functions¶
|
Returns the Skeleton-Class for the given kindName. That skeleton must exist, otherwise an exception is raised. |
Remove renderPreparation of nested skeletons |
|
|
Return the SkeletonInstance without renderPreparation. |
|
Checks whether an object is an SkeletonInstance that belongs to a specific Skeleton class. |
Module Contents¶
- core.skeleton.utils.skeletonByKind(kindName)¶
Returns the Skeleton-Class for the given kindName. That skeleton must exist, otherwise an exception is raised. :param kindName: The kindname to retreive the skeleton for :return: The skeleton-class for that kind
- Parameters:
kindName (str)
- Return type:
Type[core.skeleton.Skeleton]
- core.skeleton.utils.listKnownSkeletons()¶
- Returns:
A list of all known kindnames (all kindnames for which a skeleton is defined)
- Return type:
list[str]
- core.skeleton.utils.iterAllSkelClasses()¶
- Returns:
An iterator that yields each Skeleton-Class once. (Only top-level skeletons are returned, so no RefSkel classes will be included)
- Return type:
Iterable[core.skeleton.Skeleton]
- class core.skeleton.utils.SkelList(skel=None, *items)¶
Bases:
list,Generic[core.skeleton.meta.Skeleton_Cls]A typed list of
SkeletonInstanceobjects with query metadata.Returned by
Skel().all()...fetch()constructs. The generic parameter mirrors the one onSkeletonInstanceso that the element type flows through without manual casts:result: SkelList[ProductSkel] = ProductSkel().all().fetch(10) for skel in result: # skel is SkeletonInstance[ProductSkel] print(skel["price"])
Without the type parameter the class behaves exactly as before.
- Variables:
baseSkel – The base skeleton instance used to construct this list.
getCursor – Callable returning the datastore cursor for pagination.
get_orders – Callable returning the active query ordering.
renderPreparation – Render-preparation callback, set by renderers.
customQueryInfo – Arbitrary extra metadata attached by query helpers.
- Parameters:
baseSkel – The baseclass for all entries in this list
skel (Optional[SkeletonInstance[Skeleton_Cls]])
- __slots__ = ('baseSkel', 'customQueryInfo', 'getCursor', 'get_orders', 'renderPreparation')¶
- baseSkel: SkeletonInstance[Skeleton_Cls] | dict¶
- getCursor¶
- get_orders¶
- renderPreparation = None¶
- customQueryInfo¶
- core.skeleton.utils.remove_render_preparation_deep(skel)¶
Remove renderPreparation of nested skeletons
_refSkelCache can have renderPreparation too.
- Parameters:
skel (Any)
- Return type:
Any
- core.skeleton.utils.without_render_preparation(skel, full_clone=False)¶
Return the SkeletonInstance without renderPreparation.
This method is useful (and unfortunately necessary due to the ViUR design) if you call python methods from the jinja template that should work on the SkeletonInstance.accessedValues and not on the SkeletonInstance.renderAccessedValues.
If the SkeletonInstance does not have renderPreparation, it will be returned as is. If renderPreparation is enabled, a new SkeletonInstance is created. However, unless full_clone is True, the SkeletonInstance will use the identical objects as the source skeleton. It just “removes” the “renderPreparation mode” and keep it for the source skel enabled.
- Parameters:
skel (core.skeleton.SkeletonInstance)
full_clone (bool)
- Return type:
core.skeleton.SkeletonInstance
- core.skeleton.utils.is_skeletoninstance_of(obj, skel_cls, *, accept_ref_skel=True)¶
Checks whether an object is an SkeletonInstance that belongs to a specific Skeleton class.
- Parameters:
obj (Any) – The object to check.
skel_cls (type[core.skeleton.Skeleton]) – The skeleton class that will be checked against
obj.accept_ref_skel (bool) – If True,
objcan also be just a RefSkelFor``skel_cls``. If False, noRefSkelis accepted.
- Return type:
bool