diff --git a/royalnet/sculptor/__init__.py b/royalnet/sculptor/__init__.py new file mode 100644 index 00000000..4117e111 --- /dev/null +++ b/royalnet/sculptor/__init__.py @@ -0,0 +1,5 @@ +""" +This module contains many :mod:`pydantic` models that may be useful to multiple projects. +""" + +from a_base import * diff --git a/royalnet/sculptor/a_base.py b/royalnet/sculptor/a_base.py new file mode 100644 index 00000000..f7b5dfd2 --- /dev/null +++ b/royalnet/sculptor/a_base.py @@ -0,0 +1,41 @@ +""" +Base models are :class:`pydantic.BaseModel` that have specific configuration tailored for certain uses. +""" + +import pydantic + + +class RoyalnetModel(pydantic.BaseModel): + """ + A model for generic data. + """ + + class Config(pydantic.BaseModel.Config): + """ + The default :mod:`pydantic` configuration. + + .. seealso:: `Pydantic Configuration `_, + :class:`pydantic.BaseModel.Config` + """ + pass + + +class OrmModel(RoyalnetModel): + """ + A model for :mod:`sqlalchemy` table data. + """ + + class Config(RoyalnetModel.Config): + """ + A configuration which allows for the loading of data from ``__getattr__`` instead of ``__getitem__``. + + .. seealso:: `Pydantic ORM Mode `_ + """ + orm_mode = True + + +__all__ = ( + "RoyalnetModel", + "OrmModel", +)