core.bones.credential

Module Contents

Classes

CredentialBone

A bone for storing credentials. This bone is designed to store sensitive information like

class core.bones.credential.CredentialBone(*, max_length=None, **kwargs)

Bases: viur.core.bones.string.StringBone

A bone for storing credentials. This bone is designed to store sensitive information like passwords, API keys, or other secret strings. This is always empty if read from the database. If it’s saved, its ignored if its values is still empty. If its value is not empty, it will update the value in the database

Variables:

type (str) – The type identifier of the bone, set to “str.credential”.

Parameters:

max_length (int) –

Initializes a new StringBone.

Parameters:
  • caseSensitive – When filtering for values in this bone, should it be case-sensitive?

  • max_length (int) – The maximum length allowed for values of this bone. Set to None for no limitation.

  • min_length – The minimum length allowed for values of this bone. Set to None for no limitation.

  • natural_sorting – Allows a more natural sorting than the default sorting on the plain values. This uses the .sort_idx property. True enables sorting according to DIN 5007 Variant 2. With passing a callable, a custom transformer method can be set that creates the value for the index property.

  • kwargs – Inherited arguments from the BaseBone.

type = 'str.credential'
isInvalid(value)

Returns None if the value would be valid for this bone, an error-message otherwise.

serialize(skel, name, parentIndexed)

Serializes the bone’s value for the database.

Updates the value in the entity only if a new value is supplied. Ensures the value is never indexed.

Parameters:
  • skel (SkeletonInstance) – The skeleton instance that the bone is part of.

  • name (str) – The name of the bone attribute.

  • parentIndexed (bool) – Indicates whether the parent entity is indexed.

Returns:

True if the value was updated in the database, False otherwise.

Return type:

bool

unserialize(valuesCache, name)

Unserializes the bone’s value from the database.

This method always returns an empty dictionary as the CredentialBone’s value is always empty when read from the database.

Parameters:
  • valuesCache (dict) – A dictionary containing the serialized values from the datastore.

  • name (str) – The name of the bone attribute.

Returns:

An empty dictionary, as the CredentialBone’s value is always empty when read from the database.

Return type:

dict

singleValueFromClient(value, skel, bone_name, client_data)

Returns None and the escaped value if the value would be valid for this bone, otherwise the empty value and an error-message.