core.bones.code¶
Classes¶
Stores source code with optional language-specific syntax validation. |
|
Validates its value as a Logics expression (https://github.com/viur-framework/logics). |
|
Validates its value as a Jinja2 template. |
|
Validates its value as Python source code. |
Module Contents¶
- class core.bones.code.CodeBone(*, indexed=False, languages=None, multiple=False, syntax=None, type_suffix='', validate=True, **kwargs)¶
Bases:
viur.core.bones.raw.RawBoneStores source code with optional language-specific syntax validation.
The
syntaxparameter sets the type suffix used by the frontend for syntax highlighting, e.g.syntax="python"yieldstype = "raw.code.python".type_suffixcan override this to an arbitrary suffix.Neither
multiplenorlanguagesare supported. Settingvalidate=Falsedisables any syntax validation in subclasses.Initializes a new Bone.
- Parameters:
indexed (bool)
multiple (bool)
syntax (str | None)
type_suffix (str)
validate (bool)
- type = 'raw.code'¶
- syntax = None¶
- validate = True¶
- class core.bones.code.LogicsBone(*, syntax='logics', **kwargs)¶
Bases:
CodeBoneValidates its value as a Logics expression (https://github.com/viur-framework/logics). Uses Python syntax highlighting in the frontend.
Initializes a new Bone.
- Parameters:
syntax (str)
- singleValueFromClient(value, skel, bone_name, client_data)¶
Load a single value from a client
- Parameters:
value – The single value which should be loaded.
skel – The SkeletonInstance where the value should be loaded into.
bone_name – The bone name of this bone in the SkeletonInstance.
client_data – The data taken from the client, a dictionary with usually bone names as key
- Returns:
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.
- 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.
- class core.bones.code.JinjaBone(*, syntax='jinja2', **kwargs)¶
Bases:
CodeBoneValidates its value as a Jinja2 template.
Initializes a new Bone.
- Parameters:
syntax (str)
- 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.
- class core.bones.code.PythonBone(*, syntax='python', **kwargs)¶
Bases:
CodeBoneValidates its value as Python source code.
Initializes a new Bone.
- Parameters:
syntax (str)
- 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.