Resolving subproperties makes use of the "resolve_reference" function provided by the high level
entity class (CaosDBPythonEntity), with the following parameters:
- deep: Whether to use recursive retrieval
- references: Whether to use the supplied db.Container to resolve references. This allows offline usage. Set it to None if you want to automatically retrieve entities from the current CaosDB connection.
- visited: Needed for recursion, set this to None.
Objects in the high level representation can be serialized to a simple yaml form using the function
"serialize" with the following parameters:
- without_metadata: Set this to True if you don't want to see property metadata like "unit" or "importance".
- visited: Needed for recursion, set this to None.
This function creates a simple dictionary containing a representation of the entity, which can be
stored to disk and completely deserialized using the function "deserialize".
Furthermore the "__str__" function is overloaded, so that you can use print to directly inspect
high level objects using the following statement:
#+BEGIN_SRC python
print(str(obj))
#+END_SRC
** Concepts
As described in the section [[Quickstart]] the two functions "convert_to_python_object" and "convert_to_entity" convert
entities beetween the high level and the standard representation.
The high level entities are represented using the following classes from the module caosdb.high_level_api:
- CaosDBPythonEntity: Base class of the following entity classes.
- CaosDBPythonRecord
- CaosDBPythonRecordType
- CaosDBPythonProperty
- CaosDBPythonMultiProperty: **WARNING** Not implemented yet.
- CaosDBPythonFile: Used for file entities and provides an additional "download" function for being able to directly retrieve files from CaosDB.
In addition, there are the following helper structures which are realized as Python data classes:
- CaosDBPropertyMetaData: For storing meta data about properties.
- CaosDBPythonUnresolved: The base class of unresolved "things".
- CaosDBPythonUnresolvedParent: Parents of entities are stored as unresolved parents by default, storing an id or a name of a parent (or both).
- CaosDBPythonUnresolvedReference: An unresolved reference is a reference property with an id which has not (yet) been resolved to an Entity.
The function "resolve_references" can be used to recursively replace CaosDBPythonUnresolvedReferences into members of type CaosDBPythonRecords
or CaosDBPythonFile.
Each property stored in a CaosDB record corresponds to:
- a member attribute of CaosDBPythonRecord **and**
- an entry in a dict called "metadata" storing a CaosDBPropertyMetadata object with the following information about proeprties: