core.bones.user

Module Contents

Classes

UserBone

A specialized relational bone for handling user references. Extends the functionality of

class core.bones.user.UserBone(*, creationMagic=False, descr='User', format='$(dest.lastname), $(dest.firstname) ($(dest.name))', kind='user', readOnly=False, refKeys=('key', 'name', 'firstname', 'lastname'), updateMagic=False, visible=None, **kwargs)

Bases: viur.core.bones.relational.RelationalBone

A specialized relational bone for handling user references. Extends the functionality of viur.core.bones.relational.RelationalBone to include support for creation and update magic, and comes with a predefined descr, format, kind and refKeys setting.

Initializes a new UserBone.

Parameters:
  • creationMagic (bool) – If True, the bone will automatically store the creating user when a new entry is added.

  • updateMagic (bool) – If True, the bone will automatically store the last user who updated the entry.

  • descr (str) –

  • format (str) –

  • kind (str) –

  • readOnly (bool) –

  • refKeys (Iterable[str]) –

  • visible (Optional[bool]) –

Raises:

ValueError – If the bone is multiple=True and creation/update magic is set.

performMagic(skel, key, isAdd, *args, **kwargs)

Perform the magic operation on the bone value.

If updateMagic is enabled or creationMagic is enabled and the operation is an addition, the bone will store the current user’s key.

Parameters:
  • skel (SkeletonInstance) – The skeleton instance to operate on.

  • key (str) – The key of the bone in the skeleton.

  • isAdd (bool) – If True, the operation is an addition. Otherwise, it is an update.

  • args – Additional positional arguments.

  • kwargs – Additional keyword arguments.

Returns:

True if the magic operation was successful, False otherwise.

Return type:

bool