core.bones.boolean

Module Contents

Classes

BooleanBone

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.

Parameters:

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

Raises:

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

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.

getEmptyValue()

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

Returns:

The empty value of the BooleanBone class (False).

Return type:

bool

isEmpty(value)

Checks if the given boolean value is empty.

Parameters:

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

Returns:

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

Return type:

bool

refresh(skel, boneName)

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

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

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

  • boneName (str) –

Return type:

None

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

Builds a database filter based on the boolean value.

Parameters:
  • 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.

Returns:

The updated Query object representing the updated database filter.

Return type:

google.cloud.ndb.query.Query