pydent.models.field_value_mixins.FieldValueInterface¶
-
class
pydent.models.field_value_mixins.FieldValueInterface[source]¶ Bases:
objectA common interface for things (i.e. Operations and Samples) that have FieldValues and FieldTypes.
-
__init__()¶ Initialize self. See help(type(self)) for accurate signature.
Methods
Initialize self.
get_field_type(name, role)Returns a
pydent.models.FieldTypeby its name and role from the instance’s metaclass.get_field_types([name, role])Returns a list of
pydent.models.FieldTypeby their name and role from the instance’s metaclass.get_field_value(name[, role])Returns a
pydent.models.FieldValueby its name and role.get_field_value_array(name[, role])Returns a list of
pydent.models.FieldValueby their name and role.Returns the instance’s metatype.
Returns the routing dictionary for this instance.
new_field_value(name[, role, values_dict])Instantiates a new
pydent.models.FieldValuefrom a name and role.new_field_value_from_field_type(field_type)Instantiates a new
pydent.models.FieldValuefrom a.Safely returns the field value’s
pydent.models.FieldTypefrom the model.set_field_value(name, role, values)Sets a field value name and role using a dictionary, as in the following:
set_field_value_array(name, role, values_array)Sets an array of field values by name and role using an array of dictionaries, as in the following:
update_field_values(value_dict[, role])-
get_field_type(name, role)[source]¶ Returns a
pydent.models.FieldTypeby its name and role from the instance’s metaclass.- Parameters
name (basestring) – its name
role (basestring) – its role
- Returns
metatypes field type or None if not found
- Return type
FieldType | None
-
get_field_types(name=None, role=None)[source]¶ Returns a list of
pydent.models.FieldTypeby their name and role from the instance’s metaclass.- Parameters
name (basestring) – its name
role (basestring) – its role
- Returns
list of field types
- Return type
list
-
get_field_value(name, role=None)[source]¶ Returns a
pydent.models.FieldValueby its name and role.- Parameters
name (basestring) – its name
role (basestring) – its role
- Returns
the field value or None if not found
- Return type
FieldValue | None
-
get_field_value_array(name, role=None)[source]¶ Returns a list of
pydent.models.FieldValueby their name and role.- Parameters
name (basestring) – its name
role (basestring) – its role
- Returns
list of field values
- Return type
list
-
get_metatype()[source]¶ Returns the instance’s metatype.
The metatype is either
pydent.models.SampleTypeorpydent.models.OperationType). The metatype class name is stored as METATYPE in the class definition.- Returns
the metatype
- Return type
-
get_routing()[source]¶ Returns the routing dictionary for this instance.
- Returns
routing dictionary
- Return type
dict
-
new_field_value(name, role=None, values_dict=None)[source]¶ Instantiates a new
pydent.models.FieldValuefrom a name and role. The should be a field type with the name and role in the metatype. Optionally, a values dictionary may be provided with the following format:values_dict = { "value": None, "sample": mysample, "item": myitem, "object_type": None }- Parameters
name (basestring) – its name
role (basestring) – its role
values_dict (dict) – values to set the new field value
- Returns
the new field value
- Return type
-
new_field_value_from_field_type(field_type, values_dict=None)[source]¶ Instantiates a new
pydent.models.FieldValuefrom a.pydent.models.FieldTypeinstance. Optionally, a values dictionary may be provided with the following format:values_dict = { "value": None, "sample": mysample, "item": myitem, "object_type": None }- Parameters
field_type (FieldType) – field type to instantiate the field value
values_dict (dict) – values to set the new field value
- Returns
the new field value
- Return type
-
safe_get_field_type(fv)[source]¶ Safely returns the field value’s
pydent.models.FieldTypefrom the model.If the field value has no reference to the field type, its metatype (e.g.
pydent.models.SampleTypeorpydent.models.OperationType) is used to recover the field type.
-