Objects (objetto.objects)

Objects.

Object Class

class objetto.objects.ObjectMeta(name, bases, dct)

Metaclass for objetto.objects.Object.

Inherits from:
Features:
  • Support for objetto.objects.Attribute descriptors.

  • Compute and store attribute dependencies.

  • Constructs automatic Data class.

Raises
  • TypeError – Attribute is delegated but no delegates were defined.

  • TypeError – Attribute declares a dependency which is not available.

property _attribute_type

Attribute type.

Return type

type[objetto.objects.Attribute]

property _attributes

Attributes mapped by name.

Return type

dict[str, objetto.objects.Attribute]

property _attribute_names

Names mapped by attribute.

Return type

dict[objetto.objects.Attribute, str]

property _state_factory

State factory.

Return type

type[objetto.states.DictState]

property _attribute_dependencies

Attribute dependencies.

Return type

dict[str, set[str]]

property _attribute_dependents

Attribute dependents.

Return type

dict[str, set[str]]

property _attribute_flattened_dependencies

Flattened attribute dependencies.

Return type

dict[str, set[str]]

property _attribute_flattened_dependents

Flattened attribute dependents.

Return type

dict[str, set[str]]

property Data

Data type.

Return type

type[objetto.data.Data]

class objetto.objects.Object(app, **initial)

Object.

Metaclass:
Inherits from:
Inherited by:
Parameters
classmethod _get_relationship(location)

Get relationship at location (attribute name).

Parameters

location (str) – Location (attribute name).

Returns

Relationship.

Return type

objetto.objects.Relationship

Raises

KeyError – Attribute does not exist.

classmethod _get_attribute(name)

Get attribute by name.

Parameters

name (str) – Attribute name.

Returns

Attribute.

Return type

objetto.objects.Attribute

Raises

KeyError – Attribute does not exist.

_clear()

Clear deletable attribute values.

Returns

Transformed.

Return type

objetto.objects.Object

Raises

AttributeError – No deletable attributes.

_update(*args, **kwargs)

Update multiple attribute values. Same parameters as dict.update().

Returns

Transformed.

Return type

objetto.objects.Object

Raises

AttributeError – Attribute is not changeable and already has a value.

_set(name, value)

Set attribute value.

Parameters
  • name (str) – Attribute name.

  • value – Value.

Returns

Transformed.

Return type

objetto.objects.Object

Raises

AttributeError – Attribute is not changeable and already has a value.

_delete(name)

Delete attribute value.

Parameters

name (str) – Attribute name.

Returns

Transformed.

Return type

objetto.objects.Object

Raises
_locate(child)

Locate child object.

Parameters

child (objetto.bases.BaseObject) – Child object.

Returns

Location.

Return type

str

Raises

ValueError – Could not locate child.

_locate_data(child)

Locate child object’s data.

Parameters

child (objetto.bases.BaseObject) – Child object.

Returns

Data location.

Return type

str

Raises

ValueError – Could not locate child’s data.

classmethod deserialize(serialized, app=None, **kwargs)

Deserialize.

Parameters
Returns

Deserialized.

Return type

objetto.objects.Object

Raises

ValueError – Missing required ‘app’ attribute.

serialize(**kwargs)

Serialize.

Parameters

kwargs – Keyword arguments to be passed to the serializers.

Returns

Serialized.

Return type

dict[str, Any]

property _state

State.

Return type

objetto.states.DictState[str, Any]

property data

Data.

Return type

objetto.data.Data

Attributes

objetto.objects.attribute(types=(), subtypes=False, checked=None, module=None, factory=None, serialized=None, serializer=None, deserializer=None, represented=True, child=True, history=None, data=None, custom_data_relationship=None, default=<objetto._bases.bases.MISSING object>, default_factory=None, required=True, changeable=None, deletable=None, finalized=False, abstracted=False, metadata=None, delegated=False, dependencies=None, deserialize_to=None, batch_name=None)

Make attribute.

Parameters
  • types (str or type or None or tuple[str or type or None]) – Types.

  • subtypes (bool) – Whether to accept subtypes.

  • checked (bool) – Whether to perform runtime type check.

  • module (str or None) – Module path for lazy types/factories.

  • factory (str or collections.abc.Callable or None) – Value factory.

  • serialized (bool) – Whether should be serialized.

  • serializer (str or collections.abc.Callable or None) – Custom serializer.

  • deserializer (str or collections.abc.Callable or None) – Custom deserializer.

  • represented (bool) – Whether should be represented.

  • child (bool) – Whether object values should be adopted as children.

  • history (bool) – Whether to propagate the history to the child object value.

  • data (bool) – Whether to generate data for the value.

  • custom_data_relationship (objetto.data.DataRelationship or None) – Custom data relationship.

  • default – Default value.

  • default_factory (str or collections.abc.Callable or None) – Default value factory.

  • required (bool) – Whether attribute is required to have a value or not.

  • changeable (bool) – Whether attribute value can be changed.

  • deletable (bool) – Whether attribute value can be deleted.

  • finalized (bool) – If True, attribute can’t be overridden by subclasses.

  • abstracted (bool) – If True, attribute needs to be overridden by subclasses.

  • metadata – Metadata.

  • delegated (bool) – Whether attribute allows for delegates to be defined.

  • dependencies (collections.abc.Iterable[objetto.objects.Attribute] or objetto.objects.Attribute or None) – Attributes needed by the getter delegate.

  • deserialize_to (objetto.objects.Attribute or None) – Non-serialized attribute to deserialize this into.

  • batch_name (str or None) – Batch name.

Returns

Attribute.

Return type

objetto.objects.Attribute

Raises
  • TypeError – Invalid parameter type.

  • ValueError – Invalid parameter value.

  • ValueError – Can’t declare same dependency more than once.

  • ValueError – Provided ‘changeable’ but ‘delegated’ is True.

  • ValueError – Provided ‘deletable’ but ‘delegated’ is True.

  • ValueError – Provided ‘dependencies’ but ‘delegated’ is False.

  • ValueError – Provided ‘deserialize_to’ but ‘serialized’ is False.

  • ValueError – Can’t provide a serialized attribute to ‘deserialize_to’.

objetto.objects.constant_attribute(value, subtypes=False, checked=True, serialized=False, serializer=None, deserializer=None, represented=False, data=True, finalized=False, abstracted=False, metadata=None)

Make constant attribute.

Parameters
  • value – Constant value.

  • subtypes (bool) – Whether to accept subtypes.

  • checked (bool) – Whether to type check when overriding this constant attribute.

  • serialized (bool) – Whether should be serialized.

  • serializer (str or collections.abc.Callable or None) – Custom serializer.

  • deserializer (str or collections.abc.Callable or None) – Custom deserializer.

  • represented (bool) – Whether should be represented.

  • data (bool) – Whether to generate data for the value.

  • finalized (bool) – If True, attribute can’t be overridden by subclasses.

  • abstracted (bool) – If True, attribute needs to be overridden by subclasses.

  • metadata – Metadata.

Returns

Constant attribute.

Return type

objetto.objects.Attribute

Raises

Auxiliary Attributes

objetto.objects.protected_attribute_pair(types=(), subtypes=False, checked=None, module=None, factory=None, serialized=None, serializer=None, deserializer=None, represented=True, child=True, history=None, data=None, custom_data_relationship=None, default=<objetto._bases.bases.MISSING object>, default_factory=None, changeable=None, deletable=None, finalized=False, abstracted=False, metadata=None, protected_metadata=None, batch_name=None)

Make protected-public attribute pair.

Parameters
  • types (str or type or None or tuple[str or type or None]) – Types.

  • subtypes (bool) – Whether to accept subtypes.

  • checked (bool) – Whether to perform runtime type check.

  • module (str or None) – Module path for lazy types/factories.

  • factory (str or collections.abc.Callable or None) – Value factory.

  • serialized (bool) – Whether should be serialized.

  • serializer (str or collections.abc.Callable or None) – Custom serializer.

  • deserializer (str or collections.abc.Callable or None) – Custom deserializer.

  • represented (bool) – Whether should be represented.

  • child (bool) – Whether object values should be adopted as children.

  • history (bool) – Whether to propagate the history to the child object value.

  • data (bool) – Whether to generate data for the value.

  • custom_data_relationship (objetto.data.DataRelationship or None) – Custom data relationship.

  • default – Default value.

  • default_factory (str or collections.abc.Callable or None) – Default value factory.

  • changeable (bool) – Whether attribute value can be changed.

  • deletable (bool) – Whether attribute value can be deleted.

  • finalized (bool) – If True, attribute can’t be overridden by subclasses.

  • abstracted (bool) – If True, attribute needs to be overridden by subclasses.

  • metadata – Metadata.

  • protected_metadata – Protected metadata.

  • batch_name (str or None) – Batch name.

Returns

Protected-public attribute pair.

Return type

tuple[objetto.objects.Attribute, objetto.objects.Attribute]

Raises
objetto.objects.dict_attribute(types=(), subtypes=False, checked=None, module=None, factory=None, serialized=None, serializer=None, deserializer=None, represented=True, key_types=(), key_subtypes=False, key_factory=None, child=True, history=None, data=None, custom_data_relationship=None, default=<objetto._bases.bases.MISSING object>, default_factory=None, required=False, changeable=True, deletable=False, finalized=False, abstracted=False, metadata=None, qual_name=None, unique=False, reactions=None, batch_update_name=None)

Make mutable dictionary attribute.

Parameters
  • types (str or type or None or tuple[str or type or None]) – Types.

  • subtypes (bool) – Whether to accept subtypes.

  • checked (bool) – Whether to perform runtime type check.

  • module (str or None) – Module path for lazy types/factories.

  • factory (str or collections.abc.Callable or None) – Value factory.

  • serialized (bool) – Whether should be serialized.

  • serializer (str or collections.abc.Callable or None) – Custom serializer.

  • deserializer (str or collections.abc.Callable or None) – Custom deserializer.

  • represented (bool) – Whether should be represented.

  • child (bool) – Whether object values should be adopted as children.

  • history (bool) – Whether to propagate the history to the child object value.

  • data (bool) – Whether to generate data for the value.

  • custom_data_relationship (objetto.data.DataRelationship or None) – Custom data relationship.

  • key_types (str or type or None or tuple[str or type or None]) – Key types.

  • key_subtypes (bool) – Whether to accept subtypes for the keys.

  • key_factory (str or collections.abc.Callable or None) – Key factory.

  • default – Default value.

  • default_factory (str or collections.abc.Callable or None) – Default value factory.

  • required (bool) – Whether attribute is required to have a value or not.

  • changeable (bool) – Whether attribute value can be changed.

  • deletable (bool) – Whether attribute value can be deleted.

  • finalized (bool) – If True, attribute can’t be overridden by subclasses.

  • abstracted (bool) – If True, attribute needs to be overridden by subclasses.

  • metadata – Metadata.

  • qual_name (str or None) – Optional type qualified name for the generated class.

  • unique (bool) – Whether generated class should have a unique descriptor.

  • reactions (str or collections.abc.Callable or None or collections.abc.Iterable[str or collections.abc.Callable]) – Reaction functions ordered by priority.

  • batch_update_name (str or None) – Batch name for update operations.

Returns

Mutable dictionary attribute.

Return type

objetto.objects.Attribute[objetto.objects.MutableDictObject]

Raises
objetto.objects.protected_dict_attribute(types=(), subtypes=False, checked=None, module=None, factory=None, serialized=None, serializer=None, deserializer=None, represented=True, key_types=(), key_subtypes=False, key_factory=None, child=True, history=None, data=None, custom_data_relationship=None, default=<objetto._bases.bases.MISSING object>, default_factory=None, required=False, changeable=True, deletable=False, finalized=False, abstracted=False, metadata=None, qual_name=None, unique=False, reactions=None, batch_update_name=None)

Make protected dictionary attribute.

Parameters
  • types (str or type or None or tuple[str or type or None]) – Types.

  • subtypes (bool) – Whether to accept subtypes.

  • checked (bool) – Whether to perform runtime type check.

  • module (str or None) – Module path for lazy types/factories.

  • factory (str or collections.abc.Callable or None) – Value factory.

  • serialized (bool) – Whether should be serialized.

  • serializer (str or collections.abc.Callable or None) – Custom serializer.

  • deserializer (str or collections.abc.Callable or None) – Custom deserializer.

  • represented (bool) – Whether should be represented.

  • child (bool) – Whether object values should be adopted as children.

  • history (bool) – Whether to propagate the history to the child object value.

  • data (bool) – Whether to generate data for the value.

  • custom_data_relationship (objetto.data.DataRelationship or None) – Custom data relationship.

  • key_types (str or type or None or tuple[str or type or None]) – Key types.

  • key_subtypes (bool) – Whether to accept subtypes for the keys.

  • key_factory (str or collections.abc.Callable or None) – Key factory.

  • default – Default value.

  • default_factory (str or collections.abc.Callable or None) – Default value factory.

  • required (bool) – Whether attribute is required to have a value or not.

  • changeable (bool) – Whether attribute value can be changed.

  • deletable (bool) – Whether attribute value can be deleted.

  • finalized (bool) – If True, attribute can’t be overridden by subclasses.

  • abstracted (bool) – If True, attribute needs to be overridden by subclasses.

  • metadata – Metadata.

  • qual_name (str or None) – Optional type qualified name for the generated class.

  • unique (bool) – Whether generated class should have a unique descriptor.

  • reactions (str or collections.abc.Callable or None or collections.abc.Iterable[str or collections.abc.Callable]) – Reaction functions ordered by priority.

  • batch_update_name (str or None) – Batch name for update operations.

Returns

Protected dictionary attribute.

Return type

objetto.objects.Attribute[objetto.objects.DictObject]

Raises
objetto.objects.protected_dict_attribute_pair(types=(), subtypes=False, checked=None, module=None, factory=None, serialized=None, serializer=None, deserializer=None, represented=True, key_types=(), key_subtypes=False, key_factory=None, child=True, history=None, data=None, custom_data_relationship=None, default=<objetto._bases.bases.MISSING object>, default_factory=None, finalized=False, abstracted=False, metadata=None, protected_metadata=None, qual_name=None, unique=False, reactions=None, batch_update_name=None)

Make protected-public dictionary attribute pair.

Parameters
  • types (str or type or None or tuple[str or type or None]) – Types.

  • subtypes (bool) – Whether to accept subtypes.

  • checked (bool) – Whether to perform runtime type check.

  • module (str or None) – Module path for lazy types/factories.

  • factory (str or collections.abc.Callable or None) – Value factory.

  • serialized (bool) – Whether should be serialized.

  • serializer (str or collections.abc.Callable or None) – Custom serializer.

  • deserializer (str or collections.abc.Callable or None) – Custom deserializer.

  • represented (bool) – Whether should be represented.

  • child (bool) – Whether object values should be adopted as children.

  • history (bool) – Whether to propagate the history to the child object value.

  • data (bool) – Whether to generate data for the value.

  • custom_data_relationship (objetto.data.DataRelationship or None) – Custom data relationship.

  • key_types (str or type or None or tuple[str or type or None]) – Key types.

  • key_subtypes (bool) – Whether to accept subtypes for the keys.

  • key_factory (str or collections.abc.Callable or None) – Key factory.

  • default – Default value.

  • default_factory (str or collections.abc.Callable or None) – Default value factory.

  • finalized (bool) – If True, attribute can’t be overridden by subclasses.

  • abstracted (bool) – If True, attribute needs to be overridden by subclasses.

  • metadata – Metadata.

  • protected_metadata – Protected metadata.

  • qual_name (str or None) – Optional type qualified name for the generated class.

  • unique (bool) – Whether generated class should have a unique descriptor.

  • reactions (str or collections.abc.Callable or None or collections.abc.Iterable[str or collections.abc.Callable]) – Reaction functions ordered by priority.

  • batch_update_name (str or None) – Batch name for update operations.

Returns

Protected-public dictionary attribute pair.

Return type

tuple[objetto.objects.Attribute[objetto.objects.ProxyDictObject], objetto.objects.Attribute[objetto.objects.DictObject]]

Raises
objetto.objects.list_attribute(types=(), subtypes=False, checked=None, module=None, factory=None, serialized=None, serializer=None, deserializer=None, represented=True, child=True, history=None, data=None, custom_data_relationship=None, default=<objetto._bases.bases.MISSING object>, default_factory=None, required=False, changeable=True, deletable=False, finalized=False, abstracted=False, metadata=None, qual_name=None, unique=False, reactions=None, batch_insert_name=None, batch_delete_name=None, batch_update_name=None, batch_move_name=None)

Make mutable list attribute.

Parameters
  • types (str or type or None or tuple[str or type or None]) – Types.

  • subtypes (bool) – Whether to accept subtypes.

  • checked (bool) – Whether to perform runtime type check.

  • module (str or None) – Module path for lazy types/factories.

  • factory (str or collections.abc.Callable or None) – Value factory.

  • serialized (bool) – Whether should be serialized.

  • serializer (str or collections.abc.Callable or None) – Custom serializer.

  • deserializer (str or collections.abc.Callable or None) – Custom deserializer.

  • represented (bool) – Whether should be represented.

  • child (bool) – Whether object values should be adopted as children.

  • history (bool) – Whether to propagate the history to the child object value.

  • data (bool) – Whether to generate data for the value.

  • custom_data_relationship (objetto.data.DataRelationship or None) – Custom data relationship.

  • default – Default value.

  • default_factory (str or collections.abc.Callable or None) – Default value factory.

  • required (bool) – Whether attribute is required to have a value or not.

  • changeable (bool) – Whether attribute value can be changed.

  • deletable (bool) – Whether attribute value can be deleted.

  • finalized (bool) – If True, attribute can’t be overridden by subclasses.

  • abstracted (bool) – If True, attribute needs to be overridden by subclasses.

  • metadata – Metadata.

  • qual_name (str or None) – Optional type qualified name for the generated class.

  • unique (bool) – Whether generated class should have a unique descriptor.

  • reactions (str or collections.abc.Callable or None or collections.abc.Iterable[str or collections.abc.Callable]) – Reaction functions ordered by priority.

  • batch_insert_name (str or None) – Batch name for insert operations.

  • batch_delete_name (str or None) – Batch name for delete operations.

  • batch_update_name (str or None) – Batch name for update operations.

  • batch_move_name (str or None) – Batch name for move operations.

Returns

Mutable list attribute.

Return type

objetto.objects.Attribute[objetto.objects.MutableListObject]

Raises
objetto.objects.protected_list_attribute(types=(), subtypes=False, checked=None, module=None, factory=None, serialized=None, serializer=None, deserializer=None, represented=True, child=True, history=None, data=None, custom_data_relationship=None, default=<objetto._bases.bases.MISSING object>, default_factory=None, required=False, changeable=True, deletable=False, finalized=False, abstracted=False, metadata=None, qual_name=None, unique=False, reactions=None, batch_insert_name=None, batch_delete_name=None, batch_update_name=None, batch_move_name=None)

Make protected list attribute.

Parameters
  • types (str or type or None or tuple[str or type or None]) – Types.

  • subtypes (bool) – Whether to accept subtypes.

  • checked (bool) – Whether to perform runtime type check.

  • module (str or None) – Module path for lazy types/factories.

  • factory (str or collections.abc.Callable or None) – Value factory.

  • serialized (bool) – Whether should be serialized.

  • serializer (str or collections.abc.Callable or None) – Custom serializer.

  • deserializer (str or collections.abc.Callable or None) – Custom deserializer.

  • represented (bool) – Whether should be represented.

  • child (bool) – Whether object values should be adopted as children.

  • history (bool) – Whether to propagate the history to the child object value.

  • data (bool) – Whether to generate data for the value.

  • custom_data_relationship (objetto.data.DataRelationship or None) – Custom data relationship.

  • default – Default value.

  • default_factory (str or collections.abc.Callable or None) – Default value factory.

  • required (bool) – Whether attribute is required to have a value or not.

  • changeable (bool) – Whether attribute value can be changed.

  • deletable (bool) – Whether attribute value can be deleted.

  • finalized (bool) – If True, attribute can’t be overridden by subclasses.

  • abstracted (bool) – If True, attribute needs to be overridden by subclasses.

  • metadata – Metadata.

  • qual_name (str or None) – Optional type qualified name for the generated class.

  • unique (bool) – Whether generated class should have a unique descriptor.

  • reactions (str or collections.abc.Callable or None or collections.abc.Iterable[str or collections.abc.Callable]) – Reaction functions ordered by priority.

  • batch_insert_name (str or None) – Batch name for insert operations.

  • batch_delete_name (str or None) – Batch name for delete operations.

  • batch_update_name (str or None) – Batch name for update operations.

  • batch_move_name (str or None) – Batch name for move operations.

Returns

Protected list attribute.

Return type

objetto.objects.Attribute[objetto.objects.ListObject]

Raises
objetto.objects.protected_list_attribute_pair(types=(), subtypes=False, checked=None, module=None, factory=None, serialized=None, serializer=None, deserializer=None, represented=True, child=True, history=None, data=None, custom_data_relationship=None, default=<objetto._bases.bases.MISSING object>, default_factory=None, finalized=False, abstracted=False, metadata=None, protected_metadata=None, qual_name=None, unique=False, reactions=None, batch_insert_name=None, batch_delete_name=None, batch_update_name=None, batch_move_name=None)

Make protected-public list attribute pair.

Parameters
  • types (str or type or None or tuple[str or type or None]) – Types.

  • subtypes (bool) – Whether to accept subtypes.

  • checked (bool) – Whether to perform runtime type check.

  • module (str or None) – Module path for lazy types/factories.

  • factory (str or collections.abc.Callable or None) – Value factory.

  • serialized (bool) – Whether should be serialized.

  • serializer (str or collections.abc.Callable or None) – Custom serializer.

  • deserializer (str or collections.abc.Callable or None) – Custom deserializer.

  • represented (bool) – Whether should be represented.

  • child (bool) – Whether object values should be adopted as children.

  • history (bool) – Whether to propagate the history to the child object value.

  • data (bool) – Whether to generate data for the value.

  • custom_data_relationship (objetto.data.DataRelationship or None) – Custom data relationship.

  • default – Default value.

  • default_factory (str or collections.abc.Callable or None) – Default value factory.

  • finalized (bool) – If True, attribute can’t be overridden by subclasses.

  • abstracted (bool) – If True, attribute needs to be overridden by subclasses.

  • metadata – Metadata.

  • protected_metadata – Protected metadata.

  • qual_name (str or None) – Optional type qualified name for the generated class.

  • unique (bool) – Whether generated class should have a unique descriptor.

  • reactions (str or collections.abc.Callable or None or collections.abc.Iterable[str or collections.abc.Callable]) – Reaction functions ordered by priority.

  • batch_insert_name (str or None) – Batch name for insert operations.

  • batch_delete_name (str or None) – Batch name for delete operations.

  • batch_update_name (str or None) – Batch name for update operations.

  • batch_move_name (str or None) – Batch name for move operations.

Returns

Protected-public list attribute pair.

Return type

tuple[objetto.objects.Attribute[objetto.objects.ProxyListObject], objetto.objects.Attribute[objetto.objects.ListObject]]

Raises
objetto.objects.set_attribute(types=(), subtypes=False, checked=None, module=None, factory=None, serialized=None, serializer=None, deserializer=None, represented=True, child=True, history=None, data=None, custom_data_relationship=None, default=<objetto._bases.bases.MISSING object>, default_factory=None, required=False, changeable=True, deletable=False, finalized=False, abstracted=False, metadata=None, qual_name=None, unique=False, reactions=None, batch_update_name=None, batch_remove_name=None)

Make mutable set attribute.

Parameters
  • types (str or type or None or tuple[str or type or None]) – Types.

  • subtypes (bool) – Whether to accept subtypes.

  • checked (bool) – Whether to perform runtime type check.

  • module (str or None) – Module path for lazy types/factories.

  • factory (str or collections.abc.Callable or None) – Value factory.

  • serialized (bool) – Whether should be serialized.

  • serializer (str or collections.abc.Callable or None) – Custom serializer.

  • deserializer (str or collections.abc.Callable or None) – Custom deserializer.

  • represented (bool) – Whether should be represented.

  • child (bool) – Whether object values should be adopted as children.

  • history (bool) – Whether to propagate the history to the child object value.

  • data (bool) – Whether to generate data for the value.

  • custom_data_relationship (objetto.data.DataRelationship or None) – Custom data relationship.

  • default – Default value.

  • default_factory (str or collections.abc.Callable or None) – Default value factory.

  • required (bool) – Whether attribute is required to have a value or not.

  • changeable (bool) – Whether attribute value can be changed.

  • deletable (bool) – Whether attribute value can be deleted.

  • finalized (bool) – If True, attribute can’t be overridden by subclasses.

  • abstracted (bool) – If True, attribute needs to be overridden by subclasses.

  • metadata – Metadata.

  • qual_name (str or None) – Optional type qualified name for the generated class.

  • unique (bool) – Whether generated class should have a unique descriptor.

  • reactions (str or collections.abc.Callable or None or collections.abc.Iterable[str or collections.abc.Callable]) – Reaction functions ordered by priority.

  • batch_update_name (str or None) – Batch name for update operations.

  • batch_remove_name (str or None) – Batch name for remove operations.

Returns

Mutable set attribute.

Return type

objetto.objects.Attribute[objetto.objects.MutableSetObject]

Raises
objetto.objects.protected_set_attribute(types=(), subtypes=False, checked=None, module=None, factory=None, serialized=None, serializer=None, deserializer=None, represented=True, child=True, history=None, data=None, custom_data_relationship=None, default=<objetto._bases.bases.MISSING object>, default_factory=None, required=False, changeable=True, deletable=False, finalized=False, abstracted=False, metadata=None, qual_name=None, unique=False, reactions=None, batch_update_name=None, batch_remove_name=None)

Make protected set attribute.

Parameters
  • types (str or type or None or tuple[str or type or None]) – Types.

  • subtypes (bool) – Whether to accept subtypes.

  • checked (bool) – Whether to perform runtime type check.

  • module (str or None) – Module path for lazy types/factories.

  • factory (str or collections.abc.Callable or None) – Value factory.

  • serialized (bool) – Whether should be serialized.

  • serializer (str or collections.abc.Callable or None) – Custom serializer.

  • deserializer (str or collections.abc.Callable or None) – Custom deserializer.

  • represented (bool) – Whether should be represented.

  • child (bool) – Whether object values should be adopted as children.

  • history (bool) – Whether to propagate the history to the child object value.

  • data (bool) – Whether to generate data for the value.

  • custom_data_relationship (objetto.data.DataRelationship or None) – Custom data relationship.

  • default – Default value.

  • default_factory (str or collections.abc.Callable or None) – Default value factory.

  • required (bool) – Whether attribute is required to have a value or not.

  • changeable (bool) – Whether attribute value can be changed.

  • deletable (bool) – Whether attribute value can be deleted.

  • finalized (bool) – If True, attribute can’t be overridden by subclasses.

  • abstracted (bool) – If True, attribute needs to be overridden by subclasses.

  • metadata – Metadata.

  • qual_name (str or None) – Optional type qualified name for the generated class.

  • unique (bool) – Whether generated class should have a unique descriptor.

  • reactions (str or collections.abc.Callable or None or collections.abc.Iterable[str or collections.abc.Callable]) – Reaction functions ordered by priority.

  • batch_update_name (str or None) – Batch name for update operations.

  • batch_remove_name (str or None) – Batch name for remove operations.

Returns

Protected set attribute.

Return type

objetto.objects.Attribute[objetto.objects.SetObject]

Raises
objetto.objects.protected_set_attribute_pair(types=(), subtypes=False, checked=None, module=None, factory=None, serialized=None, serializer=None, deserializer=None, represented=True, child=True, history=None, data=None, custom_data_relationship=None, default=<objetto._bases.bases.MISSING object>, default_factory=None, finalized=False, abstracted=False, metadata=None, protected_metadata=None, qual_name=None, unique=False, reactions=None, batch_update_name=None, batch_remove_name=None)

Make protected-public set attribute pair.

Parameters
  • types (str or type or None or tuple[str or type or None]) – Types.

  • subtypes (bool) – Whether to accept subtypes.

  • checked (bool) – Whether to perform runtime type check.

  • module (str or None) – Module path for lazy types/factories.

  • factory (str or collections.abc.Callable or None) – Value factory.

  • serialized (bool) – Whether should be serialized.

  • serializer (str or collections.abc.Callable or None) – Custom serializer.

  • deserializer (str or collections.abc.Callable or None) – Custom deserializer.

  • represented (bool) – Whether should be represented.

  • child (bool) – Whether object values should be adopted as children.

  • history (bool) – Whether to propagate the history to the child object value.

  • data (bool) – Whether to generate data for the value.

  • custom_data_relationship (objetto.data.DataRelationship or None) – Custom data relationship.

  • default – Default value.

  • default_factory (str or collections.abc.Callable or None) – Default value factory.

  • finalized (bool) – If True, attribute can’t be overridden by subclasses.

  • abstracted (bool) – If True, attribute needs to be overridden by subclasses.

  • metadata – Metadata.

  • protected_metadata – Protected metadata.

  • qual_name (str or None) – Optional type qualified name for the generated class.

  • unique (bool) – Whether generated class should have a unique descriptor.

  • reactions (str or collections.abc.Callable or None or collections.abc.Iterable[str or collections.abc.Callable]) – Reaction functions ordered by priority.

  • batch_update_name (str or None) – Batch name for update operations.

  • batch_remove_name (str or None) – Batch name for remove operations.

Returns

Protected-public set attribute pair.

Return type

tuple[objetto.objects.Attribute[objetto.objects.ProxySetObject], objetto.objects.Attribute[objetto.objects.SetObject]]

Raises

Auxiliary Class Factories

objetto.objects.dict_cls(types=(), subtypes=False, checked=None, module=None, factory=None, serialized=None, serializer=None, deserializer=None, represented=True, key_types=(), key_subtypes=False, key_factory=None, child=True, history=None, data=None, custom_data_relationship=None, qual_name=None, unique=False, reactions=None, batch_update_name=None)

Make auxiliary mutable dictionary object class.

Parameters
Returns

Mutable dictionary object class.

Return type

type[objetto.objects.MutableDictObject]

Raises
objetto.objects.protected_dict_cls(types=(), subtypes=False, checked=None, module=None, factory=None, serialized=None, serializer=None, deserializer=None, represented=True, key_types=(), key_subtypes=False, key_factory=None, child=True, history=None, data=None, custom_data_relationship=None, qual_name=None, unique=False, reactions=None, batch_update_name=None)

Make auxiliary protected dictionary object class.

Parameters
Returns

Protected dictionary object class.

Return type

type[objetto.objects.DictObject]

Raises
objetto.objects.list_cls(types=(), subtypes=False, checked=None, module=None, factory=None, serialized=None, serializer=None, deserializer=None, represented=True, child=True, history=None, data=None, custom_data_relationship=None, qual_name=None, unique=False, reactions=None, batch_insert_name=None, batch_delete_name=None, batch_update_name=None, batch_move_name=None)

Make auxiliary mutable list object class.

Parameters
  • types (str or type or None or tuple[str or type or None]) – Types.

  • subtypes (bool) – Whether to accept subtypes.

  • checked (bool) – Whether to perform runtime type check.

  • module (str or None) – Module path for lazy types/factories.

  • factory (str or collections.abc.Callable or None) – Value factory.

  • serialized (bool) – Whether should be serialized.

  • serializer (str or collections.abc.Callable or None) – Custom serializer.

  • deserializer (str or collections.abc.Callable or None) – Custom deserializer.

  • represented (bool) – Whether should be represented.

  • child (bool) – Whether object values should be adopted as children.

  • history (bool) – Whether to propagate the history to the child object value.

  • data (bool) – Whether to generate data for the value.

  • custom_data_relationship (objetto.data.DataRelationship or None) – Custom data relationship.

  • qual_name (str or None) – Optional type qualified name for the generated class.

  • unique (bool) – Whether generated class should have a unique descriptor.

  • reactions (str or collections.abc.Callable or None or collections.abc.Iterable[str or collections.abc.Callable]) – Reaction functions ordered by priority.

  • batch_insert_name (str or None) – Batch name for insert operations.

  • batch_delete_name (str or None) – Batch name for delete operations.

  • batch_update_name (str or None) – Batch name for update operations.

  • batch_move_name (str or None) – Batch name for move operations.

Returns

Mutable list object class.

Return type

type[objetto.objects.MutableListObject]

Raises
objetto.objects.protected_list_cls(types=(), subtypes=False, checked=None, module=None, factory=None, serialized=None, serializer=None, deserializer=None, represented=True, child=True, history=None, data=None, custom_data_relationship=None, qual_name=None, unique=False, reactions=None, batch_insert_name=None, batch_delete_name=None, batch_update_name=None, batch_move_name=None)

Make auxiliary protected list object class.

Parameters
  • types (str or type or None or tuple[str or type or None]) – Types.

  • subtypes (bool) – Whether to accept subtypes.

  • checked (bool) – Whether to perform runtime type check.

  • module (str or None) – Module path for lazy types/factories.

  • factory (str or collections.abc.Callable or None) – Value factory.

  • serialized (bool) – Whether should be serialized.

  • serializer (str or collections.abc.Callable or None) – Custom serializer.

  • deserializer (str or collections.abc.Callable or None) – Custom deserializer.

  • represented (bool) – Whether should be represented.

  • child (bool) – Whether object values should be adopted as children.

  • history (bool) – Whether to propagate the history to the child object value.

  • data (bool) – Whether to generate data for the value.

  • custom_data_relationship (objetto.data.DataRelationship or None) – Custom data relationship.

  • qual_name (str or None) – Optional type qualified name for the generated class.

  • unique (bool) – Whether generated class should have a unique descriptor.

  • reactions (str or collections.abc.Callable or None or collections.abc.Iterable[str or collections.abc.Callable]) – Reaction functions ordered by priority.

  • batch_insert_name (str or None) – Batch name for insert operations.

  • batch_delete_name (str or None) – Batch name for delete operations.

  • batch_update_name (str or None) – Batch name for update operations.

  • batch_move_name (str or None) – Batch name for move operations.

Returns

Protected list object class.

Return type

type[objetto.objects.ListObject]

Raises
objetto.objects.set_cls(types=(), subtypes=False, checked=None, module=None, factory=None, serialized=None, serializer=None, deserializer=None, represented=True, child=True, history=None, data=None, custom_data_relationship=None, qual_name=None, unique=False, reactions=None, batch_update_name=None, batch_remove_name=None)

Make auxiliary mutable set object class.

Parameters
  • types (str or type or None or tuple[str or type or None]) – Types.

  • subtypes (bool) – Whether to accept subtypes.

  • checked (bool) – Whether to perform runtime type check.

  • module (str or None) – Module path for lazy types/factories.

  • factory (str or collections.abc.Callable or None) – Value factory.

  • serialized (bool) – Whether should be serialized.

  • serializer (str or collections.abc.Callable or None) – Custom serializer.

  • deserializer (str or collections.abc.Callable or None) – Custom deserializer.

  • represented (bool) – Whether should be represented.

  • child (bool) – Whether object values should be adopted as children.

  • history (bool) – Whether to propagate the history to the child object value.

  • data (bool) – Whether to generate data for the value.

  • custom_data_relationship (objetto.data.DataRelationship or None) – Custom data relationship.

  • qual_name (str or None) – Optional type qualified name for the generated class.

  • unique (bool) – Whether generated class should have a unique descriptor.

  • reactions (str or collections.abc.Callable or None or collections.abc.Iterable[str or collections.abc.Callable]) – Reaction functions ordered by priority.

  • batch_update_name (str or None) – Batch name for update operations.

  • batch_remove_name (str or None) – Batch name for remove operations.

Returns

Mutable set object class.

Return type

type[objetto.objects.MutableSetObject]

Raises
objetto.objects.protected_set_cls(types=(), subtypes=False, checked=None, module=None, factory=None, serialized=None, serializer=None, deserializer=None, represented=True, child=True, history=None, data=None, custom_data_relationship=None, qual_name=None, unique=False, reactions=None, batch_update_name=None, batch_remove_name=None)

Make auxiliary protected set object class.

Parameters
  • types (str or type or None or tuple[str or type or None]) – Types.

  • subtypes (bool) – Whether to accept subtypes.

  • checked (bool) – Whether to perform runtime type check.

  • module (str or None) – Module path for lazy types/factories.

  • factory (str or collections.abc.Callable or None) – Value factory.

  • serialized (bool) – Whether should be serialized.

  • serializer (str or collections.abc.Callable or None) – Custom serializer.

  • deserializer (str or collections.abc.Callable or None) – Custom deserializer.

  • represented (bool) – Whether should be represented.

  • child (bool) – Whether object values should be adopted as children.

  • history (bool) – Whether to propagate the history to the child object value.

  • data (bool) – Whether to generate data for the value.

  • custom_data_relationship (objetto.data.DataRelationship or None) – Custom data relationship.

  • qual_name (str or None) – Optional type qualified name for the generated class.

  • unique (bool) – Whether generated class should have a unique descriptor.

  • reactions (str or collections.abc.Callable or None or collections.abc.Iterable[str or collections.abc.Callable]) – Reaction functions ordered by priority.

  • batch_update_name (str or None) – Batch name for update operations.

  • batch_remove_name (str or None) – Batch name for remove operations.

Returns

Protected set object class.

Return type

type[objetto.objects.SetObject]

Raises

Data Method Decorator

@objetto.objects.data_method

Decorate object methods by tagging them as data methods. The generated data class will have the decorated methods in them.

>>> from objetto.applications import Application
>>> from objetto.objects import Object, attribute, data_method

>>> class MyObject(Object):
...     value = attribute(int, default=0)
...
...     @data_method
...     def get_double(self):
...         return self.value * 2
...
>>> app = Application()
>>> my_obj = MyObject(app)
>>> my_obj.value = 42
>>> my_obj.get_double()
84
>>> my_obj.data.get_double()
84
Parameters

func (function) – The method function.

Returns

Decorated method function.

Return type

function

Unique Descriptor

objetto.objects.unique_descriptor()

Descriptor to be used when declaring an objetto.objects.Object or an objetto.data.InteractiveData container class. When used, the hash for the container will be the object ID, and the equality method will compare by identity instead of values. If accessed through an instance, the descriptor will return the unique hash based on the object’s ID.

>>> from objetto import Application, Object, unique_descriptor

>>> class UniqueObject(Object):
...     unique_hash = unique_descriptor()
...
>>> app = Application()
>>> obj = UniqueObject(app)
>>> obj.unique_hash == hash(id(obj))
True
Returns

Unique descriptor.

Return type

objetto.objects.UniqueDescriptor or objetto.data.UniqueDescriptor

History Descriptor

objetto.objects.history_descriptor(size=None)

Descriptor to be used when declaring an objetto.objects.Object class.

When used, every instance of the object class will hold a history that will keep track of its changes (and the changes of its children that define a history relationship), allowing for easy undo/redo operations. If accessed through an instance, the descriptor will return the history object.

>>> from objetto import Application, Object, attribute, history_descriptor

>>> class Person(Object):
...     history = history_descriptor()
...     name = attribute(str)
...
>>> app = Application()
>>> person = Person(app, name="Albert")
>>> person.name = "Einstein"
>>> person.history.undo()
>>> person.name
'Albert'
Parameters

size (int or None) – How many changes to remember.

Returns

History descriptor.

Return type

objetto.history.HistoryDescriptor

Auxiliary Classes

These are special types of objects that are used internally by Auxiliary Attributes to contain multiple values in different ways.

The mutable versions of Auxiliary Classes expose the mutable methods as public, whereas the internally-mutable ones have them as protected (mutable method names start with an underscore).

When subclassing Auxiliary Classes, the schema is defined by a objetto.objects.Relationship assigned to the class attribute objetto.bases.BaseAuxiliaryStructure._relationship.

Dictionary Classes

When subclassing a objetto.objects.DictObject, the schema is defined by a objetto.objects.Relationship assigned to the class attribute objetto.bases.BaseDictStructure._key_relationship.

class objetto.objects.DictObjectMeta(name, bases, dct)

Metaclass for objetto.objects.DictObject.

Inherits from:
Features:
  • Defines a state factory.

  • Defines a base auxiliary type.

  • Defines a base auxiliary data type.

property _state_factory

State factory.

Return type

type[objetto.states.DictState]

property _base_auxiliary_type

Base auxiliary object type.

Return type

type[objetto.objects.DictObject]

property _base_auxiliary_data_type

Base auxiliary data type.

Return type

type[objetto.data.DictData]

class objetto.objects.DictObject(app, initial=())

Dictionary object.

Metaclass:
Inherits from:
Inherited by:
Parameters
_BATCH_UPDATE_NAME = None

Batch name for update operations.

Type

str or None

_clear()

Clear.

Returns

Transformed.

Return type

objetto.objects.DictObject

Raises

AttributeError – No deletable attributes.

_update(*args, **kwargs)

Update keys and values. Same parameters as dict.update().

Returns

Transformed.

Return type

objetto.objects.DictObject

_set(key, value)

Set value for key.

Parameters
Returns

Transformed.

Return type

objetto.objects.DictObject

_discard(key)

Discard key if it exists.

Parameters

key (collections.abc.Hashable) – Key.

Returns

Transformed.

Return type

objetto.objects.DictObject

_remove(key)

Delete existing key.

Parameters

key (collections.abc.Hashable) – Key.

Returns

Transformed.

Return type

objetto.objects.DictObject

Raises

KeyError – Key is not present.

_locate(child)

Locate child object.

Parameters

child (objetto.bases.BaseObject) – Child object.

Returns

Location.

Return type

collections.abc.Hashable

Raises

ValueError – Could not locate child.

_locate_data(child)

Locate child object’s data.

Parameters

child (objetto.bases.BaseObject) – Child object.

Returns

Data location.

Return type

collections.abc.Hashable

Raises

ValueError – Could not locate child’s data.

classmethod deserialize(serialized, app=None, **kwargs)

Deserialize.

Parameters
Returns

Deserialized.

Return type

objetto.objects.DictObject

Raises

objetto.exceptions.SerializationError – Can’t deserialize.

serialize(**kwargs)

Serialize.

Parameters

kwargs – Keyword arguments to be passed to serializer functions.

Returns

Serialized.

Return type

dict

Raises

objetto.exceptions.SerializationError – Can’t serialize.

property _state

State.

Return type

objetto.states.DictState

property data

Data.

Return type

objetto.data.DictData

class objetto.objects.MutableDictObject(app, initial=())

Mutable dictionary object.

Inherits from:
pop(key, fallback=<objetto._bases.bases.MISSING object>)

Get value for key and remove it, return fallback value if key is not present.

Parameters
Returns

Value or fallback value.

Raises

KeyError – Key is not present and fallback value not provided.

popitem()

Get item and discard key.

Returns

Item.

Rype

tuple[collections.abc.Hashable, Any]

Raises

KeyError – Dictionary is empty.

setdefault(key, default=None)

Get the value for the specified key, insert key with default if not present.

Parameters
Returns

Existing or default value.

List Classes

class objetto.objects.ListObjectMeta(name, bases, dct)

Metaclass for objetto.objects.ListObject.

Inherits from:
Features:
  • Defines a state factory.

  • Defines a base auxiliary type.

  • Defines a base auxiliary data type.

property _state_factory

State factory.

Return type

type[objetto.states.ListState]

property _base_auxiliary_type

Base auxiliary object type.

Return type

type[objetto.objects.ListObject]

property _base_auxiliary_data_type

Base auxiliary data type.

Return type

type[objetto.data.ListData]

class objetto.objects.ListObject(app, initial=())

List object.

Metaclass:
Inherits from:
Inherited by:
Parameters
_BATCH_INSERT_NAME = None

Batch name for insert operations.

Type

str or None

_BATCH_DELETE_NAME = None

Batch name for delete operations.

Type

str or None

_BATCH_UPDATE_NAME = None

Batch name for update operations.

Type

str or None

_BATCH_MOVE_NAME = None

Batch name for move operations.

Type

str or None

__getitem__(index)

Get value/values at index/from slice.

Parameters

index (int or slice) – Index/slice.

Returns

Value/values.

Return type

Any or objetto.states.ListState

_clear()

Clear all values.

Returns

Transformed.

Return type

objetto.objects.ListObject

_insert(index, *values)

Insert value(s) at index.

Parameters
  • index (int) – Index.

  • values – Value(s).

Returns

Transformed.

Return type

objetto.objects.ListObject

Raises

ValueError – No values provided.

_append(value)

Append value at the end.

Parameters

value – Value.

Returns

Transformed.

Return type

objetto.objects.ListObject

_extend(iterable)

Extend at the end with iterable.

Parameters

iterable (collections.abc.Iterable) – Iterable.

Returns

Transformed.

Return type

objetto.objects.ListObject

_remove(value)

Remove first occurrence of value.

Parameters

value – Value.

Returns

Transformed.

Return type

objetto.objects.ListObject

Raises

ValueError – Value is not present.

_reverse()

Reverse values.

Returns

Transformed.

Return type

objetto.objects.ListObject

_move(item, target_index)

Move values internally.

Parameters
  • item (int or slice) – Index/slice.

  • target_index (int) – Target index.

Returns

Transformed.

Return type

objetto.objects.ListObject

_delete(item)

Delete values at index/slice.

Parameters

item (int or slice) – Index/slice.

Returns

Transformed.

Return type

objetto.objects.ListObject

_update(index, *values)

Update value(s) starting at index.

Parameters
  • index (int) – Index.

  • values – Value(s).

Returns

Transformed.

Return type

objetto.objects.ListObject

Raises

ValueError – No values provided.

_locate(child)

Locate child object.

Parameters

child (objetto.bases.BaseObject) – Child object.

Returns

Location.

Return type

int

Raises

ValueError – Could not locate child.

_locate_data(child)

Locate child object’s data.

Parameters

child (objetto.bases.BaseObject) – Child object.

Returns

Data location.

Return type

int

Raises

ValueError – Could not locate child’s data.

classmethod deserialize(serialized, app=None, **kwargs)

Deserialize.

Parameters
Returns

Deserialized.

Return type

objetto.objects.ListObject

Raises

objetto.exceptions.SerializationError – Can’t deserialize.

serialize(**kwargs)

Serialize.

Parameters

kwargs – Keyword arguments to be passed to the serializers.

Returns

Serialized.

Return type

list

Raises

objetto.exceptions.SerializationError – Can’t serialize.

property _state

State.

Return type

objetto.states.ListState

property data

Data.

Return type

objetto.data.ListData

class objetto.objects.MutableListObject(app, initial=())

Mutable list object.

Inherits from:
>>> from objetto import Application, Object, attribute
>>> from objetto.objects import MutableListObject, Relationship

>>> class Hobby(Object):
...     description = attribute(str)
...
>>> class HobbiesList(MutableListObject):  # inherit from MutableListObject
...     _relationship = Relationship(Hobby)  # define relationship with type
...
>>> app = Application()
>>> hobby_a = Hobby(app, description="biking")
>>> hobby_b = Hobby(app, description="gaming")
>>> hobbies = HobbiesList(app)  # make new instance
>>> hobbies.extend((hobby_a, hobby_b))  # extend list with 'hobby' objects
__getitem__(index)

Get value/values at index/from slice.

Parameters

index (int or slice) – Index/slice.

Returns

Value/values.

Return type

Any or list

__setitem__(item, value)

Set value/values at index/slice.

Parameters
Raises
__delitem__(item)

Delete value/values at index/slice.

Parameters

item (int or slice) – Index/slice.

Raises

IndexError – Slice is noncontinuous.

pop(index=- 1)

Pop value from index.

Parameters

index (int) – Index.

Returns

Value.

Set Classes

class objetto.objects.SetObjectMeta(name, bases, dct)

Metaclass for objetto.objects.SetObject.

Inherits from:
Features:
  • Defines a state factory.

  • Defines a base auxiliary type.

  • Defines a base auxiliary data type.

property _state_factory

State factory.

Return type

type[objetto.states.SetState]

property _base_auxiliary_type

Base auxiliary object type.

Return type

type[objetto.objects.SetObject]

property _base_auxiliary_data_type

Base auxiliary data type.

Return type

type[objetto.data.SetData]

class objetto.objects.SetObject(app, initial=())

Set object.

Metaclass:
Inherits from:
Inherited by:
Parameters
_BATCH_UPDATE_NAME = None

Batch name for update operations.

Type

str or None

_BATCH_REMOVE_NAME = None

Batch name for remove operations.

Type

str or None

classmethod _from_iterable(iterable)

Make set state from iterable.

Parameters

iterable (collections.abc.Iterable[collections.abc.Hashable]) – Iterable.

Returns

Set state.

Return type

objetto.objects.SetObject

_clear()

Clear all values.

Returns

Transformed.

Return type

objetto.objects.SetObject

_add(value)

Add value.

Parameters

value (collections.abc.Hashable) – Value.

Returns

Transformed.

Return type

objetto.objects.SetObject

_discard(*values)

Discard value(s).

Parameters

values (collections.abc.Hashable) – Value(s).

Returns

Transformed.

Return type

objetto.objects.SetObject

Raises

ValueError – No values provided.

_remove(*values)

Remove existing value(s).

Parameters

values (collections.abc.Hashable) – Value(s).

Returns

Transformed.

Return type

objetto.objects.SetObject

Raises
_replace(old_value, new_value)

Replace existing value with a new one.

Parameters
Returns

Transformed.

Return type

objetto.objects.SetObject

Raises

KeyError – Value is not present.

_update(iterable)

Update with iterable.

Parameters

iterable (collections.abc.Iterable[collections.abc.Hashable]) – Iterable.

Returns

Transformed.

Return type

objetto.objects.SetObject

_locate(child)

Locate child object.

Parameters

child (objetto.bases.BaseObject) – Child object.

Returns

Location (the child object itself).

Return type

objetto.bases.BaseObject

Raises

ValueError – Could not locate child.

_locate_data(child)

Locate child object’s data.

Parameters

child (objetto.bases.BaseObject) – Child object.

Returns

Data location (the child data itself).

Return type

objetto.bases.BaseData

Raises

ValueError – Could not locate child’s data.

classmethod deserialize(serialized, app=None, **kwargs)

Deserialize.

Parameters
Returns

Deserialized.

Return type

objetto.objects.SetObject

Raises

objetto.exceptions.SerializationError – Can’t deserialize.

serialize(**kwargs)

Serialize.

Parameters

kwargs – Keyword arguments to be passed to the serializers.

Returns

Serialized.

Return type

list

Raises

objetto.exceptions.SerializationError – Can’t serialize.

property _state

State.

Return type

objetto.states.LSettate

property data

Data.

Return type

objetto.data.SetData

class objetto.objects.MutableSetObject(app, initial=())

Mutable set object.

Inherits from:
pop()

Pop value.

Returns

Value.

Return type

collections.abc.Hashable

Raises

KeyError – Empty set.

intersection_update(iterable)

Intersect.

Parameters

iterable (collections.abc.Iterable) – Iterable.

symmetric_difference_update(iterable)

Symmetric difference.

Parameters

iterable (collections.abc.Iterable) – Iterable.

difference_update(iterable)

Difference.

Parameters

iterable (collections.abc.Iterable) – Iterable.

Proxy Classes

Proxy Dictionary Class

class objetto.objects.ProxyDictObject(obj)

Mutable proxy dictionary.

Inherits from:
__reversed__()

Iterate over reversed keys.

Returns

Reversed keys iterator.

Return type

collections.abc.Iterator[collections.abc.Hashable]

__getitem__(key)

Get value for key.

Parameters

key (collections.abc.Hashable) – Key.

Returns

Value.

Raises

KeyError – Invalid key.

_update(*args, **kwargs)

Update keys and values. Same parameters as dict.update().

Returns

Transformed.

Return type

objetto.objects.ProxyDictObject

_set(key, value)

Set value for key.

Parameters
Returns

Transformed.

Return type

objetto.objects.ProxyDictObject

_discard(key)

Discard key if it exists.

Parameters

key (collections.abc.Hashable) – Key.

Returns

Transformed.

Return type

objetto.objects.ProxyDictObject

_remove(key)

Delete existing key.

Parameters

key (collections.abc.Hashable) – Key.

Returns

Transformed.

Return type

objetto.objects.ProxyDictObject

Raises

KeyError – Key is not present.

get(key, fallback=None)

Get value for key, return fallback value if key is not present.

Parameters
Returns

Value or fallback value.

iteritems()

Iterate over items.

Returns

Item iterator.

Return type

collections.abc.Iterator[tuple[collections.abc.Hashable, Any]]

iterkeys()

Iterate over keys.

Returns

Keys iterator.

Return type

collections.abc.Iterator[collections.abc.Hashable]

itervalues()

Iterate over values.

Returns

Values iterator.

Return type

collections.abc.Iterator

pop(key, fallback=<objetto._bases.bases.MISSING object>)

Get value for key and remove it, return fallback value if key is not present.

Parameters
Returns

Value or fallback value.

Raises

KeyError – Key is not present and fallback value not provided.

popitem()

Get item and discard key.

Returns

Item.

Return type

tuple[collections.abc.Hashable, Any]

Raises

KeyError – Dictionary is empty.

setdefault(key, default=None)

Get the value for the specified key, insert key with default if not present.

Parameters
Returns

Existing or default value.

property _obj

Dict obje

Return type

objetto.objects.DictObject

property _state

State.

Return type

objetto.states.DictState

property data

Data.

Return type

objetto.data.DictData or None

Proxy List Class

class objetto.objects.ProxyListObject(obj)

Mutable proxy list.

Inherits from:
__setitem__(item, value)

Set value/values at index/slice.

Parameters
Raises
__delitem__(item)

Delete value/values at index/slice.

Parameters

item (int or slice) – Index/slice.

Raises

IndexError – Slice is noncontinuous.

__reversed__()

Iterate over reversed values.

Returns

Reversed values iterator.

Return type

collections.abc.Iterator

__getitem__(index)

Get value/values at index/from slice.

Parameters

index (int or slice) – Index/slice.

Returns

Value/values.

Return type

list

_insert(index, *values)

Insert value(s) at index.

Parameters
  • index (int) – Index.

  • values – Value(s).

Returns

Transformed.

Return type

objetto.objects.ProxyListObject

Raises

ValueError – No values provided.

_append(value)

Append value at the end.

Parameters

value – Value.

Returns

Transformed.

Return type

objetto.objects.ProxyListObject

_extend(iterable)

Extend at the end with iterable.

Parameters

iterable – Iterable.

Returns

Transformed.

Return type

objetto.objects.ProxyListObject

_remove(value)

Remove first occurrence of value.

Parameters

value – Value.

Returns

Transformed.

Return type

objetto.objects.ProxyListObject

Raises

ValueError – Value is not present.

_reverse()

Reverse values.

Returns

Transformed.

Return type

objetto.objects.ProxyListObject

_move(item, target_index)

Move values internally.

Parameters
  • item (int or slice) – Index/slice.

  • target_index (int) – Target index.

Returns

Transformed.

Return type

objetto.objects.ProxyListObject

_delete(item)

Delete values at index/slice.

Parameters

item (int or slice) – Index/slice.

Returns

Transformed.

Return type

objetto.objects.ProxyListObject

_update(index, *values)

Update value(s) starting at index.

Parameters
  • index (int) – Index.

  • values – Value(s).

Returns

Transformed.

Raises

ValueError – No values provided.

pop(index=- 1)

Pop value from index.

Parameters

index (int) – Index.

Returns

Value.

count(value)

Count number of occurrences of a value.

Parameters

value – Value.

Returns

Number of occurrences.

Return type

int

index(value, start=None, stop=None)

Get index of a value.

Parameters
  • value – Value.

  • start (int or None) – Start index.

  • stop (int or None) – Stop index.

Returns

Index of value.

Return type

int

Raises

ValueError – Provided stop but did not provide start.

resolve_index(index, clamp=False)

Resolve index to a positive number.

Parameters
  • index (int) – Input index.

  • clamp (bool) – Whether to clamp between zero and the length.

Returns

Resolved index.

Return type

int

Raises

IndexError – Index out of range.

resolve_continuous_slice(slc)

Resolve continuous slice according to length.

Parameters

slc (slice) – Continuous slice.

Returns

Index and stop.

Return type

tuple[int, int]

Raises

IndexError – Slice is noncontinuous.

property _obj

List object.

Return type

objetto.objects.ListObject

property _state

State.

Return type

objetto.states.ListState

property data

Data.

Return type

objetto.data.ListData or None

Proxy Set Class

class objetto.objects.ProxySetObject(obj)

Mutable proxy set.

Inherits from:
pop()

Pop value.

Returns

Value.

Return type

collections.abc.Hashable

Raises

KeyError – Empty set.

intersection_update(iterable)

Intersect.

Parameters

iterable (collections.abc.Iterable) – Iterable.

symmetric_difference_update(iterable)

Symmetric difference.

Parameters

iterable (collections.abc.Iterable) – Iterable.

difference_update(iterable)

Difference.

Parameters

iterable (collections.abc.Iterable) – Iterable.

classmethod _from_iterable(iterable)

Make set state from iterable.

Parameters

iterable (collections.abc.Iterable[collections.abc.Hashable]) – Iterable.

Returns

Set state.

Return type

objetto.objects.SetObject

_hash()

Get hash.

Returns

Hash.

Return type

int

_add(value)

Add value.

Parameters

value (collections.abc.Hashable) – Value.

Returns

Transformed.

Return type

objetto.objects.ProxySetObject

_discard(*values)

Discard value(s).

Parameters

values (collections.abc.Hashable) – Value(s).

Returns

Transformed.

Return type

objetto.objects.ProxySetObject

Raises

ValueError – No values provided.

_remove(*values)

Remove existing value(s).

Parameters

values (collections.abc.Hashable) – Value(s).

Returns

Transformed.

Return type

objetto.objects.ProxySetObject

Raises
_replace(old_value, new_value)

Replace existing value with a new one.

Parameters
Returns

Transformed.

Return type

objetto.objects.ProxySetObject

Raises

KeyError – Value is not present.

_update(iterable)

Update with iterable.

Parameters

iterable (collections.abc.Iterable[collections.abc.Hashable]) – Iterable.

Returns

Transformed.

Return type

objetto.objects.ProxySetObject

isdisjoint(iterable)

Get whether is a disjoint set of an iterable.

Parameters

iterable (collections.abc.Iterable) – Iterable.

Returns

True if is disjoint.

issubset(iterable)

Get whether is a subset of an iterable.

Parameters

iterable (collections.abc.Iterable) – Iterable.

Returns

True if is subset.

issuperset(iterable)

Get whether is a superset of an iterable.

Parameters

iterable (collections.abc.Iterable) – Iterable.

Returns

True if is superset.

intersection(iterable)

Get intersection.

Parameters

iterable (collections.abc.Iterable) – Iterable.

Returns

Intersection.

difference(iterable)

Get difference.

Parameters

iterable (collections.abc.Iterable) – Iterable.

Returns

Difference.

inverse_difference(iterable)

Get an iterable’s difference to this.

Parameters

iterable (collections.abc.Iterable) – Iterable.

Returns

Inverse Difference.

symmetric_difference(iterable)

Get symmetric difference.

Parameters

iterable (collections.abc.Iterable) – Iterable.

Returns

Symmetric difference.

union(iterable)

Get union.

Parameters

iterable (collections.abc.Iterable) – Iterable.

Returns

Union.

property _obj

Set object.

Return type

objetto.objects.SetObject

property _state

State.

Return type

objetto.states.SetState

property data

Data.

Return type

objetto.data.SetData or None

Attribute Descriptor Class

class objetto.objects.AttributeMeta(name, bases, dct)

Metaclass for objetto.objects.Attribute.

Inherits from:
Features:
  • Defines relationship type.

property _relationship_type

Relationship type.

Return type

type[objetto.objects.Relationship]

class objetto.objects.Attribute(relationship=Relationship(checked=False, child=True, data=True, data_relationship=DataRelationship(checked=False, compared=True, deserializer=None, factory=None, module=None, represented=True, serialized=True, serializer=None, subtypes=False, types=frozenset()), deserializer=None, factory=None, history=True, module=None, represented=True, serialized=True, serializer=None, subtypes=False, types=frozenset()), default=<objetto._bases.bases.MISSING object>, default_factory=None, module=None, required=True, changeable=None, deletable=None, finalized=False, abstracted=False, metadata=None, delegated=False, dependencies=None, deserialize_to=None, batch_name=None)

Attribute descriptor for objetto.objects.Object classes.

Metaclass:
Inherits from:
Parameters
  • relationship (objetto.objects.Relationship) – Relationship.

  • default – Default value.

  • default_factory (str or collections.abc.Callable or None) – Default value factory.

  • module (str or None) – Optional module path to use in case partial paths are provided.

  • required (bool) – Whether attribute is required to have a value or not.

  • changeable (bool) – Whether attribute value can be changed.

  • deletable (bool) – Whether attribute value can be deleted.

  • finalized (bool) – If True, attribute can’t be overridden by subclasses.

  • abstracted (bool) – If True, attribute needs to be overridden by subclasses.

  • metadata – Metadata.

  • delegated (bool) – Whether attribute allows for delegates to be defined.

  • dependencies (collections.abc.Iterable[objetto.objects.Attribute] or objetto.objects.Attribute or None) – Attributes needed by the getter delegate.

  • deserialize_to (objetto.objects.Attribute or None) – Non-serialized attribute to deserialize this into.

  • batch_name (str or None) – Batch name.

Raises
  • TypeError – Invalid parameter type.

  • ValueError – Invalid parameter value.

  • ValueError – Can’t declare same dependency more than once.

  • ValueError – Provided ‘changeable’ but ‘delegated’ is True.

  • ValueError – Provided ‘deletable’ but ‘delegated’ is True.

  • ValueError – Provided ‘dependencies’ but ‘delegated’ is False.

  • ValueError – Provided ‘deserialize_to’ but ‘serialized’ is False.

  • ValueError – Can’t provide a serialized attribute to ‘deserialize_to’.

__set__(instance, value)

Set attribute value.

Parameters
__delete__(instance)

Delete attribute value.

Parameters

instance (objetto.objects.Object) – Object instance.

to_dict()

Convert to dictionary.

Returns

Dictionary.

Return type

dict[str, Any]

copy(**kwargs)

Make a copy of this attribute and optionally change some of its parameters.

Parameters

kwargs – New parameters.

Returns

New attribute.

Return type

objetto.objects.Attribute

Raises
  • RuntimeError – Can’t copy delegated attribute.

  • RuntimeError – Can’t copy attribute that deserializes to another.

set_value(instance, value)

Set attribute value.

Parameters
delete_value(instance)

Delete attribute value.

Parameters

instance (objetto.objects.Object) – Object instance.

getter(func)

Define a getter delegate method.

Parameters

func (function) – Delegate function.

Returns

This attribute.

Return type

objetto.objects.Attribute

Raises
  • ValueError – Cannot define a getter for a non-delegated attribute.

  • ValueError – Getter delegate already defined.

  • TypeError – Invalid delegate type.

setter(func)

Define a setter delegate method.

Parameters

func (function) – Delegate function.

Returns

This attribute.

Return type

objetto.objects.Attribute

Raises
  • ValueError – Cannot define a setter for a non-delegated attribute.

  • ValueError – Need to define a getter before defining a setter.

  • ValueError – Setter delegate already defined.

  • TypeError – Invalid delegate type.

deleter(func)

Define a deleter delegate method.

Parameters

func (function) – Delegate function.

Returns

This attribute.

Return type

objetto.objects.Attribute

Raises
  • ValueError – Cannot define a deleter for a non-delegated attribute.

  • ValueError – Need to define a getter before defining a deleter.

  • ValueError – Deleter delegate already defined.

  • TypeError – Invalid delegate type.

property relationship

Relationship.

Return type

objetto.objects.Relationship

property delegated

Whether attribute allows for delegates to be defined.

Return type

bool

property dependencies

Attributes needed by the getter delegate.

Return type

tuple[objetto.objects.Attribute]

property deserialize_to

Non-serialized attribute to deserialize this into.

Return type

objetto.objects.Attribute or None

property fget

Getter delegate.

Return type

function or None

property fset

Setter delegate.

Return type

function or None

property fdel

Deleter delegate.

Return type

function or None

property constant

Whether attribute is constant.

Return type

bool

property batch_name

Batch name.

Return type

str or None

property data_attribute

Data attribute.

Return type

objetto.data.DataAttribute or None

Relationship Classes

class objetto.objects.Relationship(types=(), subtypes=False, checked=None, module=None, factory=None, serialized=None, serializer=None, deserializer=None, represented=True, child=True, history=None, data=None, data_relationship=None)

Relationship between an object structure and its values.

Inherits from:
Parameters
  • types (str or type or None or tuple[str or type or None]) – Types.

  • subtypes (bool) – Whether to accept subtypes.

  • checked (bool) – Whether to perform runtime type check.

  • module (str or None) – Module path for lazy types/factories.

  • factory (str or collections.abc.Callable or None) – Value factory.

  • serialized (bool) – Whether should be serialized.

  • serializer (str or collections.abc.Callable or None) – Custom serializer.

  • deserializer (str or collections.abc.Callable or None) – Custom deserializer.

  • represented (bool) – Whether should be represented.

  • child (bool) – Whether object values should be adopted as children.

  • history (bool) – Whether to propagate the history to the child object value.

  • data (bool) – Whether to generate data for the value.

  • data_relationship (objetto.data.DataRelationship or None) – Data relationship (will be generated if not provided).

Raises
  • TypeError – Invalid parameter type.

  • ValueError – Invalid parameter value.

  • ValueError – Provided ‘serialized’ but ‘child’ is False.

  • ValueError – Provided ‘history’ but ‘child’ is False.

  • ValueError – Provided ‘data’ but ‘child’ is False.

  • ValueError – Provided ‘data_relationship’ but ‘child’ is False

  • ValueError – Provided ‘data_relationship’ but ‘data’ is False.

to_dict()

Convert to dictionary.

Returns

Dictionary.

Return type

Dict[str, Any]

property child

Whether object values should be adopted as children.

Return type

bool

property history

Whether to propagate the history to the child object value.

Return type

bool

property data

Whether to generate data for the value.

Return type

bool

property data_relationship

Data relationship.

Return type

objetto.data.DataRelationship or None

class objetto.objects.KeyRelationship(types=(), subtypes=False, checked=None, module=None, factory=None)

Relationship between a dictionary auxiliary structure and their keys.

Inherits from:
Parameters
  • types (str or type or None or tuple[str or type or None]) – Types.

  • subtypes (bool) – Whether to accept subtypes.

  • checked (bool) – Whether to perform runtime type check.

  • module (str or None) – Module path for lazy types/factories.

  • factory (str or collections.abc.Callable or None) – Key factory.

Raises
__hash__()

Get hash.

Returns

Hash.

Return type

int

__eq__(other)

Compare with another object for equality.

Parameters

other – Another object.

Returns

True if considered equal.

Return type

bool

__repr__()

Get representation.

Returns

Representation.

Return type

str

to_dict()

Convert to dictionary.

Returns

Dictionary.

Return type

dict[str, Any]

fabricate_key(key, factory=True, **kwargs)

Perform type check and run key through factory.

Parameters
  • key (collections.abc.Hashable) – Key.

  • factory (bool) – Whether to run value through factory.

  • kwargs – Keyword arguments to be passed to the factory.

Returns

Fabricated value.

property types

Types.

Return type

tuple[str or type]

property subtypes

Whether to accept subtypes.

Return type

bool

property checked

Whether to perform runtime type check.

Return type

bool

property module

Module path for lazy types/factories.

Return type

str or None

property factory

Key factory.

Return type

str or collections.abc.Callable or None

property passthrough

Whether does not perform type checks and has no factory.

Return type

bool

Unique Descriptor Class

class objetto.objects.UniqueDescriptor

Descriptor to be used on objetto.bases.BaseStructure classes. When used, the object ID will be the hash, and the equality method will compare by identity instead of by values. If accessed through an instance, the descriptor will return the object ID.

Inherits from:
__get__(instance, owner)

Get object hash when accessing from instance or this descriptor otherwise.

Parameters
Returns

Object hash based on object ID or this descriptor.

Return type

int or objetto.objects.UniqueDescriptor or objetto.data.UniqueDescriptor

Action Class

class objetto.objects.Action(**initial)

Carries information about a change and where it happened in the hierarchy.

Inherits from:
sender :  Data Attribute

Object where the action originated from (where the change happened).

Type

objetto.bases.BaseObject

receiver :  Data Attribute

Object relaying the action up the hierarchy.

Type

objetto.bases.BaseObject

locations :  Data Attribute

List of relative locations from the receiver to the sender.

Type

list[str or int or collections.abc.Hashable]

change :  Data Attribute

Change that happened in the sender.

Type

objetto.bases.BaseChange