core.modules.script

Module Contents

Classes

BaseScriptAbstractSkel

This is a container-object holding information about one database entity.

ScriptNodeSkel

This is a container-object holding information about one database entity.

ScriptLeafSkel

This is a container-object holding information about one database entity.

Script

Tree module prototype.

Attributes

DIRECTORY_PATTERN

FILE_PATTERN

core.modules.script.DIRECTORY_PATTERN
core.modules.script.FILE_PATTERN
class core.modules.script.BaseScriptAbstractSkel(*args, **kwargs)

Bases: viur.core.prototypes.tree.TreeSkel

This is a container-object holding information about one database entity.

It has to be sub-classed with individual information about the kindName of the entities and its specific data attributes, the so called bones. The Skeleton stores its bones in an OrderedDict-Instance, so the definition order of the contained bones remains constant.

Variables:
  • key (server.bones.BaseBone) – This bone stores the current database key of this entity. Assigning to this bones value is dangerous and does not affect the actual key its stored in.

  • creationdate (server.bones.DateBone) – The date and time where this entity has been created.

  • changedate (server.bones.DateBone) – The date and time of the last change to this entity.

path
classmethod fromClient(skel, data, *args, **kwargs)

This function works similar to setValues(), except that the values retrieved from data are checked against the bones and their validity checks.

Even if this function returns False, all bones are guaranteed to be in a valid state. The ones which have been read correctly are set to their valid values; Bones with invalid values are set back to a safe default (None in most cases). So its possible to call toDB() afterwards even if reading data with this function failed (through this might violates the assumed consistency-model).

Parameters:
  • skel – The skeleton instance to be filled.

  • data – Dictionary from which the data is read.

  • amend – Defines whether content of data may be incomplete to amend the skel, which is useful for edit-actions.

Returns:

True if all data was successfully read and complete. False otherwise (e.g. some required fields where missing or where invalid).

class core.modules.script.ScriptNodeSkel(*args, **kwargs)

Bases: BaseScriptAbstractSkel

This is a container-object holding information about one database entity.

It has to be sub-classed with individual information about the kindName of the entities and its specific data attributes, the so called bones. The Skeleton stores its bones in an OrderedDict-Instance, so the definition order of the contained bones remains constant.

Variables:
  • key (server.bones.BaseBone) – This bone stores the current database key of this entity. Assigning to this bones value is dangerous and does not affect the actual key its stored in.

  • creationdate (server.bones.DateBone) – The date and time where this entity has been created.

  • changedate (server.bones.DateBone) – The date and time of the last change to this entity.

kindName = 'viur-script-node'
rootNode
plugin
name
class core.modules.script.ScriptLeafSkel(*args, **kwargs)

Bases: BaseScriptAbstractSkel

This is a container-object holding information about one database entity.

It has to be sub-classed with individual information about the kindName of the entities and its specific data attributes, the so called bones. The Skeleton stores its bones in an OrderedDict-Instance, so the definition order of the contained bones remains constant.

Variables:
  • key (server.bones.BaseBone) – This bone stores the current database key of this entity. Assigning to this bones value is dangerous and does not affect the actual key its stored in.

  • creationdate (server.bones.DateBone) – The date and time where this entity has been created.

  • changedate (server.bones.DateBone) – The date and time of the last change to this entity.

kindName = 'viur-script-leaf'
name
script
access
class core.modules.script.Script(moduleName, modulePath, *args, **kwargs)

Bases: viur.core.prototypes.tree.Tree

Tree module prototype.

It is used for hierarchical structures, either as a tree with nodes and leafs, or as a hierarchy with nodes only.

leafSkelCls
nodeSkelCls
roles
adminInfo()
getAvailableRootNodes()

Default function for providing a list of root node items. This list is requested by several module-internal functions and must be overridden by a custom functionality. The default stub for this function returns an empty list. An example implementation could be the following:

# Example
def getAvailableRootNodes(self, *args, **kwargs):
    q = db.Query(self.rootKindName)
    ret = [{"key": str(e.key()),
        "name": e.get("name", str(e.key().id_or_name()))} #FIXME
        for e in q.run(limit=25)]
    return ret
Parameters:
  • args – Can be used in custom implementations.

  • kwargs – Can be used in custom implementations.

Returns:

Returns a list of dicts which must provide a “key” and a “name” entry with respective information.

onEdit(skelType, skel)

Hook function that is called before editing an entry.

It can be overridden for a module-specific behavior.

Parameters:
  • skelType – Defines the type of the node that shall be edited.

  • skel – The Skeleton that is going to be edited.

See also

edit(), onEdited()

onEdited(skelType, skel)

Hook function that is called after modifying an entry.

It should be overridden for a module-specific behavior. The default is writing a log entry.

Parameters:
  • skelType – Defines the type of the node that has been edited.

  • skel – The Skeleton that has been modified.

See also

edit(), onEdit()

update_path_recursive(skel_type, path, parent_key, cursor=None)

Recursively updates all items under a given parent key.

update_path(skel)

Updates the path-value of a either a folder or a script file, by resolving the repository’s root node.