core.skeleton.tasks =================== .. py:module:: core.skeleton.tasks Classes ------- .. autoapisummary:: core.skeleton.tasks.SkelIterTask core.skeleton.tasks.SkeletonMaintenanceTask Functions --------- .. autoapisummary:: core.skeleton.tasks.update_relations Module Contents --------------- .. py:function:: 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. :param key: The database-key of the entity that has been edited :param min_change_time: 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 :param changed_bones: 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. :param cursor: The database cursor for the current request as we only process five entities at once and then defer again. .. py:class:: SkelIterTask Bases: :py:obj:`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. .. py:method:: handleEntry(skel, data) :classmethod: 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). .. py:method:: handleError(skel, data, exception) :classmethod: Handle a error occurred in handleEntry. If this function returns True, the queryIter continues, otherwise it breaks and prints the current cursor. .. py:method:: handleFinish(total, data) :classmethod: Overridable hook that indicates the current run has been finished. .. py:class:: SkeletonMaintenanceTask Bases: :py:obj:`viur.core.tasks.CallableTaskBase` Base class for user-callable tasks. Must be subclassed. .. py:attribute:: key :value: 'SkeletonMaintenanceTask' .. py:attribute:: name :value: 'Skeleton Maintenance' .. py:attribute:: descr :value: 'Perform filtered maintenance operations on skeletons.' .. py:method:: canCall() Checks wherever the current user can execute this task :returns: bool .. py:class:: dataSkel Bases: :py:obj:`core.skeleton.relskel.RelSkel` If additional data is needed, return a skeleton-instance here. These values are then passed to *execute*. .. py:attribute:: task .. py:attribute:: kinds .. py:class:: FilterRowUsingSkel Bases: :py:obj:`core.skeleton.relskel.RelSkel` .. py:attribute:: name .. py:attribute:: op .. py:attribute:: value .. py:attribute:: filters .. py:attribute:: condition .. py:method:: execute(task, kinds, filters, condition) The actual code that should be run goes here.