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.Attributedescriptors.Compute and store attribute dependencies.
Constructs automatic Data class.
- Raises
- property _attribute_type
Attribute type.
- Return type
- property _attributes
Attributes mapped by name.
- Return type
- property _attribute_names
Names mapped by attribute.
- Return type
- property _state_factory
State factory.
- Return type
- property _attribute_flattened_dependencies
Flattened attribute dependencies.
- property _attribute_flattened_dependents
Flattened attribute dependents.
- property Data
Data type.
- Return type
- class objetto.objects.Object(app, **initial)
Object.
- Metaclass:
- Inherits from:
- Inherited by:
- Parameters
app (objetto.applications.Application) – Application.
initial – Initial values.
- classmethod _get_relationship(location)
Get relationship at location (attribute name).
- classmethod _get_attribute(name)
Get attribute by name.
- _clear()
Clear deletable attribute values.
- Returns
Transformed.
- Return type
- Raises
AttributeError – No deletable attributes.
- _update(*args, **kwargs)
Update multiple attribute values. Same parameters as
dict.update().- Returns
Transformed.
- Return type
- 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
- 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
- Raises
KeyError – Attribute does not exist or has no value.
AttributeError – Attribute is not deletable.
- _locate(child)
Locate child object.
- Parameters
child (objetto.bases.BaseObject) – Child object.
- Returns
Location.
- Return type
- 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
- Raises
ValueError – Could not locate child’s data.
- classmethod deserialize(serialized, app=None, **kwargs)
Deserialize.
- Parameters
app (objetto.applications.Application) – Application (required).
kwargs – Keyword arguments to be passed to the deserializers.
- Returns
Deserialized.
- Return type
- Raises
ValueError – Missing required ‘app’ attribute.
- serialize(**kwargs)
Serialize.
- property _state
State.
- Return type
objetto.states.DictState[str, Any]
- property data
Data.
- Return type
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
- 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
- Raises
TypeError – Invalid parameter type.
ValueError – Invalid parameter value.
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
- Raises
TypeError – Invalid parameter type.
ValueError – Invalid parameter value.
- 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
TypeError – Invalid parameter type.
ValueError – Invalid parameter value.
- 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
- Raises
TypeError – Invalid parameter type.
ValueError – Invalid parameter value.
- 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
TypeError – Invalid parameter type.
ValueError – Invalid parameter value.
- 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
TypeError – Invalid parameter type.
ValueError – Invalid parameter value.
- 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
- Raises
TypeError – Invalid parameter type.
ValueError – Invalid parameter value.
- 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
TypeError – Invalid parameter type.
ValueError – Invalid parameter value.
- 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
- Raises
TypeError – Invalid parameter type.
ValueError – Invalid parameter value.
- 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
- Raises
TypeError – Invalid parameter type.
ValueError – Invalid parameter value.
- 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
TypeError – Invalid parameter type.
ValueError – Invalid parameter value.
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
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.
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 object class.
- Return type
- Raises
TypeError – Invalid parameter type.
ValueError – Invalid parameter value.
- 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
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.
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 object class.
- Return type
- Raises
TypeError – Invalid parameter type.
ValueError – Invalid parameter value.
- 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
- Raises
TypeError – Invalid parameter type.
ValueError – Invalid parameter value.
- 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
- Raises
TypeError – Invalid parameter type.
ValueError – Invalid parameter value.
- 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
- Raises
TypeError – Invalid parameter type.
ValueError – Invalid parameter value.
- 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
- Raises
TypeError – Invalid parameter type.
ValueError – Invalid parameter value.
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.Objector anobjetto.data.InteractiveDatacontainer 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.Objectclass.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.
Note
Prefer using Auxiliary Attributes or Auxiliary Class Factories over Auxiliary Classes directly.
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
- property _base_auxiliary_type
Base auxiliary object type.
- Return type
- property _base_auxiliary_data_type
Base auxiliary data type.
- Return type
- class objetto.objects.DictObject(app, initial=())
Dictionary object.
- Metaclass:
- Inherits from:
- Inherited by:
- Parameters
app (objetto.applications.Application) – Application.
initial (collections.abc.Mapping or collections.abc.Iterable[tuple[collections.abc.Hashable, Any]]) – Initial values.
- _clear()
Clear.
- Returns
Transformed.
- Return type
- Raises
AttributeError – No deletable attributes.
- _update(*args, **kwargs)
Update keys and values. Same parameters as
dict.update().- Returns
Transformed.
- Return type
- _set(key, value)
Set value for key.
- Parameters
key (collections.abc.Hashable) – Key.
value – Value.
- Returns
Transformed.
- Return type
- _discard(key)
Discard key if it exists.
- Parameters
key (collections.abc.Hashable) – Key.
- Returns
Transformed.
- Return type
- _remove(key)
Delete existing key.
- Parameters
key (collections.abc.Hashable) – Key.
- Returns
Transformed.
- Return type
- Raises
KeyError – Key is not present.
- _locate(child)
Locate child object.
- Parameters
child (objetto.bases.BaseObject) – Child object.
- Returns
Location.
- Return type
- 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
- Raises
ValueError – Could not locate child’s data.
- classmethod deserialize(serialized, app=None, **kwargs)
Deserialize.
- Parameters
serialized (dict) – Serialized.
app (objetto.applications.Application) – Application (required).
kwargs – Keyword arguments to be passed to the deserializers.
- Returns
Deserialized.
- Return type
- Raises
objetto.exceptions.SerializationError – Can’t deserialize.
- serialize(**kwargs)
Serialize.
- Parameters
kwargs – Keyword arguments to be passed to serializer functions.
- Returns
Serialized.
- Return type
- Raises
objetto.exceptions.SerializationError – Can’t serialize.
- property _state
State.
- Return type
- property data
Data.
- Return type
- 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
key (collections.abc.Hashable) – Key.
fallback – Fallback value.
- 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
key (collections.abc.Hashable) – Key.
default – Default value.
- 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
- property _base_auxiliary_type
Base auxiliary object type.
- Return type
- property _base_auxiliary_data_type
Base auxiliary data type.
- Return type
- class objetto.objects.ListObject(app, initial=())
List object.
- Metaclass:
- Inherits from:
- Inherited by:
- Parameters
app (objetto.applications.Application) – Application.
initial (collections.abc.Iterable) – Initial values.
- __getitem__(index)
Get value/values at index/from slice.
- Parameters
- Returns
Value/values.
- Return type
Any or objetto.states.ListState
- _clear()
Clear all values.
- Returns
Transformed.
- Return type
- _insert(index, *values)
Insert value(s) at index.
- Parameters
index (int) – Index.
values – Value(s).
- Returns
Transformed.
- Return type
- Raises
ValueError – No values provided.
- _append(value)
Append value at the end.
- Parameters
value – Value.
- Returns
Transformed.
- Return type
- _extend(iterable)
Extend at the end with iterable.
- Parameters
iterable (collections.abc.Iterable) – Iterable.
- Returns
Transformed.
- Return type
- _remove(value)
Remove first occurrence of value.
- Parameters
value – Value.
- Returns
Transformed.
- Return type
- Raises
ValueError – Value is not present.
- _reverse()
Reverse values.
- Returns
Transformed.
- Return type
- _move(item, target_index)
Move values internally.
- Parameters
- Returns
Transformed.
- Return type
- _delete(item)
Delete values at index/slice.
- Parameters
- Returns
Transformed.
- Return type
- _update(index, *values)
Update value(s) starting at index.
- Parameters
index (int) – Index.
values – Value(s).
- Returns
Transformed.
- Return type
- Raises
ValueError – No values provided.
- _locate(child)
Locate child object.
- Parameters
child (objetto.bases.BaseObject) – Child object.
- Returns
Location.
- Return type
- 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
- Raises
ValueError – Could not locate child’s data.
- classmethod deserialize(serialized, app=None, **kwargs)
Deserialize.
- Parameters
serialized (list) – Serialized.
app (objetto.applications.Application) – Application (required).
kwargs – Keyword arguments to be passed to the deserializers.
- Returns
Deserialized.
- Return type
- Raises
objetto.exceptions.SerializationError – Can’t deserialize.
- serialize(**kwargs)
Serialize.
- Parameters
kwargs – Keyword arguments to be passed to the serializers.
- Returns
Serialized.
- Return type
- Raises
objetto.exceptions.SerializationError – Can’t serialize.
- property _state
State.
- Return type
- property data
Data.
- Return type
- 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.
- __setitem__(item, value)
Set value/values at index/slice.
- Parameters
value (Any or collections.abc.Iterable) – Value/values.
- Raises
IndexError – Slice is noncontinuous.
ValueError – Values length does not fit in slice.
- __delitem__(item)
Delete value/values at index/slice.
- Parameters
- Raises
IndexError – Slice is noncontinuous.
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
- property _base_auxiliary_type
Base auxiliary object type.
- Return type
- property _base_auxiliary_data_type
Base auxiliary data type.
- Return type
- class objetto.objects.SetObject(app, initial=())
Set object.
- Metaclass:
- Inherits from:
- Inherited by:
- Parameters
app (objetto.applications.Application) – Application.
initial (collections.abc.Iterable[collections.abc.Hashable]) – Initial values.
- classmethod _from_iterable(iterable)
Make set state from iterable.
- Parameters
iterable (collections.abc.Iterable[collections.abc.Hashable]) – Iterable.
- Returns
Set state.
- Return type
- _clear()
Clear all values.
- Returns
Transformed.
- Return type
- _add(value)
Add value.
- Parameters
value (collections.abc.Hashable) – Value.
- Returns
Transformed.
- Return type
- _discard(*values)
Discard value(s).
- Parameters
values (collections.abc.Hashable) – Value(s).
- Returns
Transformed.
- Return type
- Raises
ValueError – No values provided.
- _remove(*values)
Remove existing value(s).
- Parameters
values (collections.abc.Hashable) – Value(s).
- Returns
Transformed.
- Return type
- Raises
ValueError – No values provided.
KeyError – Value is not present.
- _replace(old_value, new_value)
Replace existing value with a new one.
- Parameters
old_value (collections.abc.Hashable) – Existing value.
new_value (collections.abc.Hashable) – New value.
- Returns
Transformed.
- Return type
- Raises
KeyError – Value is not present.
- _update(iterable)
Update with iterable.
- Parameters
iterable (collections.abc.Iterable[collections.abc.Hashable]) – Iterable.
- Returns
Transformed.
- Return type
- _locate(child)
Locate child object.
- Parameters
child (objetto.bases.BaseObject) – Child object.
- Returns
Location (the child object itself).
- Return type
- 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
- Raises
ValueError – Could not locate child’s data.
- classmethod deserialize(serialized, app=None, **kwargs)
Deserialize.
- Parameters
serialized (list) – Serialized.
app (objetto.applications.Application) – Application (required).
kwargs – Keyword arguments to be passed to the deserializers.
- Returns
Deserialized.
- Return type
- Raises
objetto.exceptions.SerializationError – Can’t deserialize.
- serialize(**kwargs)
Serialize.
- Parameters
kwargs – Keyword arguments to be passed to the serializers.
- Returns
Serialized.
- Return type
- Raises
objetto.exceptions.SerializationError – Can’t serialize.
- property _state
State.
- Return type
objetto.states.LSettate
- property data
Data.
- Return type
- class objetto.objects.MutableSetObject(app, initial=())
Mutable set object.
- Inherits from:
- 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
- __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
- _set(key, value)
Set value for key.
- Parameters
key (collections.abc.Hashable) – Key.
value – Value.
- Returns
Transformed.
- Return type
- _discard(key)
Discard key if it exists.
- Parameters
key (collections.abc.Hashable) – Key.
- Returns
Transformed.
- Return type
- _remove(key)
Delete existing key.
- Parameters
key (collections.abc.Hashable) – Key.
- Returns
Transformed.
- Return type
- Raises
KeyError – Key is not present.
- get(key, fallback=None)
Get value for key, return fallback value if key is not present.
- Parameters
key (collections.abc.Hashable) – Key.
fallback – Fallback value.
- 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
- itervalues()
Iterate over values.
- Returns
Values iterator.
- Return type
- pop(key, fallback=<objetto._bases.bases.MISSING object>)
Get value for key and remove it, return fallback value if key is not present.
- Parameters
key (collections.abc.Hashable) – Key.
fallback – Fallback value.
- 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
- Raises
KeyError – Dictionary is empty.
- setdefault(key, default=None)
Get the value for the specified key, insert key with default if not present.
- Parameters
key (collections.abc.Hashable) – Key.
default – Default value.
- Returns
Existing or default value.
- property _obj
Dict obje
- Return type
- property _state
State.
- Return type
- 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
value (Any or collections.abc.Iterable) – Value/values.
- Raises
IndexError – Slice is noncontinuous.
ValueError – Values length does not fit in slice.
- __delitem__(item)
Delete value/values at index/slice.
- Parameters
- Raises
IndexError – Slice is noncontinuous.
- __reversed__()
Iterate over reversed values.
- Returns
Reversed values iterator.
- Return type
- __getitem__(index)
Get value/values at index/from slice.
- _insert(index, *values)
Insert value(s) at index.
- Parameters
index (int) – Index.
values – Value(s).
- Returns
Transformed.
- Return type
- Raises
ValueError – No values provided.
- _append(value)
Append value at the end.
- Parameters
value – Value.
- Returns
Transformed.
- Return type
- _extend(iterable)
Extend at the end with iterable.
- Parameters
iterable – Iterable.
- Returns
Transformed.
- Return type
- _remove(value)
Remove first occurrence of value.
- Parameters
value – Value.
- Returns
Transformed.
- Return type
- Raises
ValueError – Value is not present.
- _reverse()
Reverse values.
- Returns
Transformed.
- Return type
- _move(item, target_index)
Move values internally.
- Parameters
- Returns
Transformed.
- Return type
- _delete(item)
Delete values at index/slice.
- Parameters
- Returns
Transformed.
- Return type
- _update(index, *values)
Update value(s) starting at index.
- Parameters
index (int) – Index.
values – Value(s).
- Returns
Transformed.
- Raises
ValueError – No values provided.
- count(value)
Count number of occurrences of a value.
- Parameters
value – Value.
- Returns
Number of occurrences.
- Return type
- index(value, start=None, stop=None)
Get index of a value.
- Parameters
- Returns
Index of value.
- Return type
- Raises
ValueError – Provided stop but did not provide start.
- resolve_index(index, clamp=False)
Resolve index to a positive number.
- Parameters
- Returns
Resolved index.
- Return type
- 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
- Raises
IndexError – Slice is noncontinuous.
- property _obj
List object.
- Return type
- property _state
State.
- Return type
- property data
Data.
- Return type
objetto.data.ListData or None
Proxy Set Class
- class objetto.objects.ProxySetObject(obj)
Mutable proxy set.
- Inherits from:
- 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
- _add(value)
Add value.
- Parameters
value (collections.abc.Hashable) – Value.
- Returns
Transformed.
- Return type
- _discard(*values)
Discard value(s).
- Parameters
values (collections.abc.Hashable) – Value(s).
- Returns
Transformed.
- Return type
- Raises
ValueError – No values provided.
- _remove(*values)
Remove existing value(s).
- Parameters
values (collections.abc.Hashable) – Value(s).
- Returns
Transformed.
- Return type
- Raises
ValueError – No values provided.
KeyError – Value is not present.
- _replace(old_value, new_value)
Replace existing value with a new one.
- Parameters
old_value (collections.abc.Hashable) – Existing value.
new_value – New value.
- Returns
Transformed.
- Return type
- Raises
KeyError – Value is not present.
- _update(iterable)
Update with iterable.
- Parameters
iterable (collections.abc.Iterable[collections.abc.Hashable]) – Iterable.
- Returns
Transformed.
- Return type
- 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
- property _state
State.
- Return type
- 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
- 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.Objectclasses.- 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
instance (objetto.objects.Object) – Object instance.
value – Value.
- __delete__(instance)
Delete attribute value.
- Parameters
instance (objetto.objects.Object) – Object instance.
- copy(**kwargs)
Make a copy of this attribute and optionally change some of its parameters.
- Parameters
kwargs – New parameters.
- Returns
New attribute.
- Return type
- Raises
RuntimeError – Can’t copy delegated attribute.
RuntimeError – Can’t copy attribute that deserializes to another.
- set_value(instance, value)
Set attribute value.
- Parameters
instance (objetto.objects.Object) – Object instance.
value – Value.
- 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
- 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
- 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
- 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
- property dependencies
Attributes needed by the getter delegate.
- Return type
- 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 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.
- 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
- Raises
TypeError – Invalid parameter type.
ValueError – Invalid parameter value.
- __eq__(other)
Compare with another object for equality.
- Parameters
other – Another object.
- Returns
True if considered equal.
- Return type
- 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 factory
Key factory.
- Return type
str or collections.abc.Callable or None
Unique Descriptor Class
- class objetto.objects.UniqueDescriptor
Descriptor to be used on
objetto.bases.BaseStructureclasses. 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
instance (objetto.bases.BaseStructure or None) – Instance.
owner (type[objetto.bases.BaseStructure] or None) – Owner class.
- 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).
- receiver : Data Attribute
Object relaying the action up the hierarchy.
- 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.