Entity module¶
Base entity for modeling of API’s
-
class
nova_api.entity.Entity(id_: str = <factory>, creation_datetime: datetime.datetime = <factory>, last_modified_datetime: datetime.datetime = <factory>)[source]¶ Base Entity implementation
This class is the base implementation of the entity for modeling API resources. The fields included in this class will be inherited for all subclasses.
Examples
@dataclass class Person(Entity): name: str = None age: int = None birthday: date = None
-
__post_init__()[source]¶ Post processing of fields
Post init goes through the parameters passed to init and makes some validations. Fields that are subclasses of Entity will be instantiated (but only with id_ set). Datetime formats also will be cast if received as strings. Strings will have trailing and leading white spaces removed.
__post_init__ may be overridden to include validations required by any use case. In such case, it’s important to include a super call to maintain the aforementioned functionalities.
Returns: None
-
__weakref__¶ list of weak references to the object (if defined)
-
get_db_values() → list[source]¶ Returns all attributes to save in database with formatted values.
Goes through the fields in the entity and converts them to the expected value to save in the database. For example: datetime values are converted to string with the specific sql format.
Also verifies if a field contains in metadata database=False and excludes it from the list if so. Default for database is True.
Returns: Serialized values to save in database
-