core.modules.script¶
Classes¶
This is a container-object holding information about one database entity. |
|
This is a container-object holding information about one database entity. |
|
This is a container-object holding information about one database entity. |
|
Script is a system module used to serve a filesystem for scripts used by ViUR Scriptor and ViUR CLI. |
Module Contents¶
- class core.modules.script.BaseScriptAbstractSkel(*args, **kwargs)¶
Bases:
viur.core.prototypes.tree.TreeSkelThis 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
write()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.
ignore – optional list of bones to be ignored; Defaults to all readonly-bones when set to None.
- 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:
BaseScriptAbstractSkelThis 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'¶
Specifies the entity kind name this Skeleton is associated with. Will be determined automatically when not explicitly set.
- rootNode¶
- plugin¶
- name¶
- class core.modules.script.ScriptLeafSkel(*args, **kwargs)¶
Bases:
BaseScriptAbstractSkelThis 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'¶
Specifies the entity kind name this Skeleton is associated with. Will be determined automatically when not explicitly set.
- name¶
- script¶
- access¶
- class core.modules.script.Script(moduleName, modulePath, *args, **kwargs)¶
Bases:
viur.core.prototypes.tree.TreeScript is a system module used to serve a filesystem for scripts used by ViUR Scriptor and ViUR CLI.
- leafSkelCls¶
- nodeSkelCls¶
- roles¶
Allows to specify role settings for a module.
Defaults to no role definition, which ignores the module entirely in the role-system. In this case, access rights can still be set individually on the user’s access bone.
A “*” wildcard can either be used as key or as value to allow for “all roles”, or “all rights”.
# Example roles = { "*": "view", # Any role may only "view" "editor": ("add", "edit"), # Role "editor" may "add" or "edit", but not "delete" "admin": "*", # Role "admin" can do everything }
- adminInfo()¶
This is a
dictholding the information necessary for the Vi/Admin to handle this module.- name:
str Human-readable module name that will be shown in the admin tool.
- handler:
str(list,treeorsingleton): Allows to override the handler provided by the module. Set this only when really necessary, otherwise it can be left out and is automatically injected by the Module’s prototype.
- icon:
str (Optional) Either the Shoelace icon library name or a path relative to the project’s deploy folder (e.g. /static/icons/viur.svg) for the icon used in the admin tool for this module.
- columns:
List[str] (Optional) List of columns (bone names) that are displayed by default. Used only by the List handler.
- filter:
Dict[str, str] (Optional) Dictionary of additional parameters that will be send along when fetching entities from the server. Can be used to filter the entities being displayed on the client-side.
- display:
str(“default”, “hidden” or “group”) (Optional) “hidden” will hide the module in the admin tool’s main bar. (itwill not be accessible directly, however it’s registered with the frontend so it can be used in a relational bone). “group” will show this module in the main bar, but it will not be clickable. Clicking it will just try to expand it (assuming there are additional views defined).
- preview:
Union[str, Dict[str, str]] (Optional) A url that will be opened in a new tab and is expected to display the entity selected in the table. Can be “/{{module}}/view/{{key}}”, with {{module}} and {{key}} getting replaced as needed. If more than one preview-url is needed, supply a dictionary where the key is the URL and the value the description shown to the user.
- views:
List[Dict[str, t.Any]] (Optional) List of nested adminInfo like dictionaries. Used to define additional views on the module. Useful f.e. for an order module, where you want separate list of “payed orders”, “unpayed orders”, “orders waiting for shipment”, etc. If such views are defined, the top-level entry in the menu bar will expand if clicked, revealing these additional filters.
- actions:
List[str] (Optional) List of actions supported by this modules. Actions can be defined by the frontend (like “add”, “edit”, “delete” or “preview”); it can be an action defined by a plugin loaded by the frontend; or it can be a so called “server side action” (see “customActions” below)
- customActions:
Dict[str, dict] (Optional) A mapping of names of server-defined actions that can be used in the
actionslist above to their definition dictionary. See …. for more details.- disabledActions:
List[str, dict] (Optional) A list of disabled actions. The frontend will inject default actions like add or edit even if they’re not listed in actions. Listing them here will prevent that. It’s up to the frontend to decide if that action won’t be visible at all or it’s button just being disabled.
- sortIndex:
int (Optional) Defines the order in which the modules will appear in the main bar in ascrending order.
- indexedBones:
List[str] (Optional) List of bones, for which an (composite?) index exists in this view. This allows the fronted to signal the user that a given list can be sorted or filtered by this bone. If no additional filters are enforced by the
listFilterandfilteris not set, this should be all bones which are marked as indexed.- changeInvalidates:
List[str] (Optional) A list of module-names which depend on the entities handled from this module. This allows the frontend to invalidate any caches in these depended modules if the data in this module changes. Example: This module may be a list-module handling the file_rootNode entities for the file module, so a edit/add/deletion action on this module should be reflected in the rootNode-selector in the file-module itself. In this case, this property should be set to
["file"].- moduleGroup:
str (Optional) If set, should be a key of a moduleGroup defined in …. .
- editViews:
Dict[str, t.Any] (Optional) If set, will embed another list-widget in the edit forms for a given entity. See …. for more details.
If this is a function, it must take no parameters and return the dictionary as shown above. This can be used to customize the appearance of the Vi/Admin to individual users.
- name:
- 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.
- view(skelType, key, *args, **kwargs)¶
Prepares and renders a single entry for viewing.
The entry is fetched by its key and its skelType. The function performs several access control checks on the requested entity before it is rendered.
See also
canView(),onView()- Returns:
The rendered representation of the requested entity.
- Parameters:
skelType (viur.core.prototypes.tree.SkelType) – May either be “node” or “leaf”.
key (viur.core.db.Key | int | str) – URL-safe key of the parent.
- Raises:
viur.core.errors.NotAcceptable, when an incorrect skelType is provided.- Raises:
viur.core.errors.NotFound, when no entry with the given key was found.- Raises:
viur.core.errors.Unauthorized, if the current user does not have the required permissions.- Return type:
Any
- 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.
- get_importable()¶