core.bones.boolean ================== .. py:module:: core.bones.boolean Attributes ---------- .. autoapisummary:: core.bones.boolean.DEFAULT_VALUE_T Classes ------- .. autoapisummary:: core.bones.boolean.BooleanBone Module Contents --------------- .. py:type:: DEFAULT_VALUE_T :canonical: bool | None | list[bool] | dict[str, list[bool] | bool] .. py:class:: BooleanBone(*, defaultValue = None, **kwargs) Bases: :py:obj:`viur.core.bones.base.BaseBone` Represents a boolean data type, which can have two possible values: `True` or `False`. It also allows for `None` to specify the "not yet set"-state. BooleanBones cannot be defined as `multiple=True`. :param defaultValue: The default value of the `BooleanBone` instance. Defaults to `None` (unset). :raises ValueError: If the `defaultValue` is not either a boolean value (`True` or `False`) or `None`. Initializes a new Bone. .. py:attribute:: type :value: 'bool' .. 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:: getEmptyValue() Returns the empty value of the `BooleanBone` class, which is `False`. :return: The empty value of the `BooleanBone` class (`False`). :rtype: bool .. py:method:: isEmpty(value) Checks if the given boolean value is empty. :param value: The boolean value to be checked. :return: `True` if the boolean value is empty (i.e., equal to the empty value of the `BooleanBone` class), `False` otherwise. :rtype: bool .. py:method:: refresh(skel, name) Inverse of serialize. Evaluates whats read from the datastore and populates this bone accordingly. :param name: The property-name this bone has in its Skeleton (not the description!) .. py:method:: 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. :param skel: Dictionary with the current values from the skeleton the bone belongs to :param boneName: The name of the bone that should be modified :param value: The value that should be assigned. Its type depends on the type of the bone :param append: If True, the given value will be appended to the existing bone values instead of replacing them. Only supported on bones with multiple=True :param language: Optional, the language of the value if the bone is language-aware :return: A boolean indicating whether the operation succeeded or not :rtype: bool .. py:method:: 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. .. py:method:: buildDBFilter(name, skel, dbFilter, rawFilter, prefix = None) Builds a database filter based on the boolean value. :param name: The name of the `BooleanBone` instance. :param skel: The `SkeletonInstance` object representing the data of the current entity. :param dbFilter: The `Query` object representing the current database filter. :param rawFilter: The dictionary representing the raw filter data received from the client. :param prefix: A prefix to be added to the property name in the database filter. :return: The updated `Query` object representing the updated database filter. :rtype: google.cloud.ndb.query.Query