tortoise_orm#

class starlite.plugins.tortoise_orm.TortoiseORMPlugin#

Bases: PluginProtocol[Model]

Support (de)serialization and OpenAPI generation for Tortoise ORMtypes.

to_pydantic_model_class(model_class: Type[Model], **kwargs: Any) Type[PydanticModel]#

Given a tortoise model_class instance, convert it to a subclass of the tortoise PydanticModel.

Since incoming request body’s cannot and should not include values for related fields, pk fields and read only fields in tortoise-orm, we generate two different kinds of pydantic models here: - the first is a regular pydantic model, and the other is for the “data” kwarg only, which is further sanitized.

This function uses memoization to ensure we don’t recompute unnecessarily.

static is_plugin_supported_type(value: Any) TypeGuard[Model]#

Given a value of indeterminate type, determine if this value is supported by the plugin.

from_pydantic_model_instance(model_class: Type[Model], pydantic_model_instance: BaseModel) Model#

Given an instance of a pydantic model created using the plugin’s to_pydantic_model_class, return an instance of the class from which that pydantic model has been created.

This class is passed in as the model_class kwarg.

async to_dict(model_instance: Model) Dict[str, Any]#

Given an instance of a model supported by the plugin, return a dictionary of serializable values.

from_dict(model_class: Type[Model], **kwargs: Any) Model#

Given a class supported by this plugin and a dict of values, create an instance of the class.