core.skeleton.tasks

Classes

SkelIterTask

Iterates the skeletons of a query, and additionally checks a Logics expression.

SkeletonMaintenanceTask

Base class for user-callable tasks.

Functions

update_relations(key, *[, min_change_time, ...])

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.QueryIter

Iterates 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.CallableTaskBase

Base 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.RelSkel

If additional data is needed, return a skeleton-instance here. These values are then passed to execute.

task
kinds
class FilterRowUsingSkel

Bases: core.skeleton.relskel.RelSkel

name
op
value
filters
condition
execute(task, kinds, filters, condition)

The actual code that should be run goes here.