core.skeleton.tasks¶
Classes¶
Iterates the skeletons of a query, and additionally checks a Logics expression. |
|
Base class for user-callable tasks. |
Functions¶
|
This function updates Entities, which may have a copy of values from another entity which has been recently |
Module Contents¶
- core.skeleton.tasks.update_relations(key, *, min_change_time=None, changed_bones=(), cursor=None, total=0, **kwargs)¶
This function updates Entities, which may have a copy of values from another entity which has been recently edited (updated). In ViUR, relations are implemented by copying the values from the referenced entity into the entity that’s referencing them. This allows ViUR to run queries over properties of referenced entities and prevents additional db.Get’s to these referenced entities if the main entity is read. However, this forces us to track changes made to entities as we might have to update these mirrored values. This is the deferred call from meth:viur.core.skeleton.Skeleton.write() after an update (edit) on one Entity to do exactly that.
- Parameters:
key (viur.core.db.Key) – The database-key of the entity that has been edited
min_change_time (Optional[float]) – The timestamp on which the edit occurred. As we run deferred, and the entity might have been edited multiple times before we get acutally called, we can ignore entities that have been updated in the meantime as they’re already up-to-date
changed_bones (Optional[Iterable[str] | str]) – If set, we’ll update only entites that have a copy of that bones. Relations mirror only key and name by default, so we don’t have to update these if only another bone has been changed.
cursor (Optional[str]) – The database cursor for the current request as we only process five entities at once and then defer again.
total (int)
- class core.skeleton.tasks.SkelIterTask¶
Bases:
viur.core.tasks.QueryIterIterates the skeletons of a query, and additionally checks a Logics expression. When the skeleton is valid, it performs the action data[“action”] on each entry.
- classmethod handleEntry(skel, data)¶
Overridable hook to process one entry. “entry” will be either an db.Entity or an SkeletonInstance (if that query has been created by skel.all())
Warning: If your query has an sortOrder other than __key__ and you modify that property here it is possible to encounter that object later one again (as it may jump behind the current cursor).
- classmethod handleError(skel, data, exception)¶
Handle a error occurred in handleEntry. If this function returns True, the queryIter continues, otherwise it breaks and prints the current cursor.
- Return type:
bool
- classmethod handleFinish(total, data)¶
Overridable hook that indicates the current run has been finished.
- class core.skeleton.tasks.SkeletonMaintenanceTask¶
Bases:
viur.core.tasks.CallableTaskBaseBase class for user-callable tasks. Must be subclassed.
- key = 'SkeletonMaintenanceTask'¶
- name = 'Skeleton Maintenance'¶
- descr = 'Perform filtered maintenance operations on skeletons.'¶
- canCall()¶
Checks wherever the current user can execute this task :returns: bool
- class dataSkel¶
Bases:
core.skeleton.relskel.RelSkelThis is a Skeleton-like class that acts as a container for Skeletons used as a additional information data skeleton for
RelationalBone.It needs to be sub-classed where information about the kindName and its attributes (bones) are specified.
The Skeleton stores its bones in an
OrderedDict-Instance, so the definition order of the contained bones remains constant.- task¶
- kinds¶
- class FilterRowUsingSkel¶
Bases:
core.skeleton.relskel.RelSkelThis is a Skeleton-like class that acts as a container for Skeletons used as a additional information data skeleton for
RelationalBone.It needs to be sub-classed where information about the kindName and its attributes (bones) are specified.
The Skeleton stores its bones in an
OrderedDict-Instance, so the definition order of the contained bones remains constant.- name¶
- op¶
- value¶
- filters¶
- condition¶
- execute(task, kinds, filters, condition)¶
The actual code that should be run goes here.