Module Contents



Represents a boolean data type, which can have two possible values: True or False.

class core.bones.boolean.BooleanBone(*, defaultValue=None, **kwargs)

Bases: viur.core.bones.base.BaseBone

Represents a boolean data type, which can have two possible values: True or False. BooleanBones cannot be defined as multiple=True.


defaultValue (bool) – The default value of the BooleanBone instance. Defaults to False.


ValueError – If the defaultValue is not a boolean value (True or False).

Initializes a new Bone.

type = 'bool'
singleValueFromClient(value, skel, bone_name, client_data)

Load a single value from a client

  • 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


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.


Returns the empty value of the BooleanBone class, which is False.


The empty value of the BooleanBone class (False).

Return type:



Checks if the given boolean value is empty.


value (Any) – The boolean value to be checked.


True if the boolean value is empty (i.e., equal to the empty value of the BooleanBone class), False otherwise.

Return type:


refresh(skel, boneName)

Inverse of serialize. Evaluates whats read from the datastore and populates this bone accordingly.

  • name – The property-name this bone has in its Skeleton (not the description!)

  • skel (viur.core.skeleton.SkeletonInstance) –

  • boneName (str) –

Return type:


setBoneValue(skel, boneName, value, append, language=None)

Sets the value of the bone to the provided ‘value’. Sanity checks are performed; if the value is invalid, the bone value will revert to its original (default) value and the function will return False.

  • skel (SkeletonInstance) – Dictionary with the current values from the skeleton the bone belongs to

  • boneName (str) – The name of the bone that should be modified

  • value (Any) – The value that should be assigned. Its type depends on the type of the bone

  • append (bool) – If True, the given value will be appended to the existing bone values instead of replacing them. Only supported on bones with multiple=True

  • language (None | str) – Optional, the language of the value if the bone is language-aware


A boolean indicating whether the operation succeeded or not

Return type:


singleValueSerialize(value, skel, name, parentIndexed)

Serializes a single value of the bone for storage in the database.

Derived bone classes should overwrite this method to implement their own logic for serializing single values. The serialized value should be suitable for storage in the database.

buildDBFilter(name, skel, dbFilter, rawFilter, prefix=None)

Builds a database filter based on the boolean value.

  • name (str) – The name of the BooleanBone instance.

  • skel (viur.core.skeleton.SkeletonInstance) – The SkeletonInstance object representing the data of the current entity.

  • dbFilter (viur.core.db.Query) – The Query object representing the current database filter.

  • rawFilter (dict) – The dictionary representing the raw filter data received from the client.

  • prefix (Optional[str]) – A prefix to be added to the property name in the database filter.


The updated Query object representing the updated database filter.

Return type: