core.bones.code =============== .. py:module:: core.bones.code Classes ------- .. autoapisummary:: core.bones.code.CodeBone core.bones.code.LogicsBone core.bones.code.JinjaBone core.bones.code.PythonBone Module Contents --------------- .. py:class:: CodeBone(*, indexed = False, languages=None, multiple = False, syntax = None, type_suffix = '', validate = True, **kwargs) Bases: :py:obj:`viur.core.bones.raw.RawBone` Stores source code with optional language-specific syntax validation. The ``syntax`` parameter sets the type suffix used by the frontend for syntax highlighting, e.g. ``syntax="python"`` yields ``type = "raw.code.python"``. ``type_suffix`` can override this to an arbitrary suffix. Neither ``multiple`` nor ``languages`` are supported. Setting ``validate=False`` disables any syntax validation in subclasses. Initializes a new Bone. .. py:attribute:: type :value: 'raw.code' .. py:attribute:: syntax :value: None .. py:attribute:: validate :value: True .. py:class:: LogicsBone(*, syntax = 'logics', **kwargs) Bases: :py:obj:`CodeBone` Validates its value as a Logics expression (https://github.com/viur-framework/logics). Uses Python syntax highlighting in the frontend. Initializes a new Bone. .. py:method:: singleValueFromClient(value, skel, bone_name, client_data) Load a single value from a client :param value: The single value which should be loaded. :param skel: The SkeletonInstance where the value should be loaded into. :param bone_name: The bone name of this bone in the SkeletonInstance. :param client_data: The data taken from the client, a dictionary with usually bone names as key :return: A tuple. If the value is valid, the first element is the parsed value and the second is None. If the value is invalid or not parseable, the first element is a empty value and the second a list of *ReadFromClientError*. .. py:method:: isInvalid(value) Checks if the current value of the bone in the given skeleton is invalid. Returns None if the value would be valid for this bone, an error-message otherwise. .. py:class:: JinjaBone(*, syntax = 'jinja2', **kwargs) Bases: :py:obj:`CodeBone` Validates its value as a Jinja2 template. Initializes a new Bone. .. py:method:: isInvalid(value) Checks if the current value of the bone in the given skeleton is invalid. Returns None if the value would be valid for this bone, an error-message otherwise. .. py:class:: PythonBone(*, syntax = 'python', **kwargs) Bases: :py:obj:`CodeBone` Validates its value as Python source code. Initializes a new Bone. .. py:method:: isInvalid(value) Checks if the current value of the bone in the given skeleton is invalid. Returns None if the value would be valid for this bone, an error-message otherwise.