{ "info": { "author": "Victor Klapholz", "author_email": "victor.klapholz@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy" ], "description": "***********************************************************************\n:fire:toastedmarshmallow-models:fire:: Create Serializable Class Models\n***********************************************************************\n\nInspired by `Marshmallow Models `_ and by ORM libraries.\n\nThe Toasted Marshmallow Models package makes it easy to define serializable classes based on the ultra fast\nserialization that `Toasted Marshmallow `_ provides.\n\n\nInstalling toastedmarshmallow-models\n------------------------------------\n\n.. code-block:: bash\n\n pip install toastedmarshmallow-models\n\n\nUsing Toasted Marshmallow Models\n--------------------------------\n\nUsing Toasted Marshmallow Models in an existing class requires your class to inherit\nthe ``Model`` class and specify the relevant ``Marshmallow fields``. For example:\n\n.. code-block:: python\n\n from marshmallow import fields\n from toastedmarshmallow_models import Model\n\n class Entity(Model): # Inherit Model\n # Define Marshmallow fields\n id = fields.Integer()\n name = fields.String()\n\n def __init__(self, id, name):\n self.id = id\n self.name = name\n\n\nHow it works\n------------\n\nThe Toasted Marshmallow Models package makes it easy to ``dump`` and ``load`` models.\n\n\n``Dump methods:``\n\n.. code-block:: python\n\n entity = Entity(id=1, name='John Doe')\n\n print(entity.to_dict())\n # {\"id\": 1, \"name\": \"John\"}\n\n print(entity.to_json())\n # '{\"id\": 1, \"name\": \"John\"}'\n\n\n``Load Methods:``\n\n.. code-block:: python\n\n entity = Entity.from_dict({\"id\": 1, \"name\": \"John\"}) # creates an Entity instance\n\n entity = Entity.from_json('{\"id\": 1, \"name\": \"John\"}') # creates an Entity instance\n\n\nFeatures\n--------\n\n``Validation:``\n\n.. code-block:: python\n\n entity = Entity(id='i-am-not-a-valid-int', name='John Doe')\n\n entity.validate() # throws marshmallow.ValidationError if not valid\n\n\n``Get validation errors:``\n\n.. code-block:: python\n\n entity = Entity(id='i-am-not-a-valid-int', name='John Doe')\n\n entity.get_validation_errors() # returns dict(id=['Not a valid integer.'])\n\n\n``Nested Models:``\n\n.. code-block:: python\n\n class ChildEntity(Model):\n name = fields.String()\n\n def __init__(self, name: str):\n self.name = name\n\n\n class ParentEntity(Model):\n name = fields.String()\n # Use NestedModel to define parent-child relationships\n children = fields.Nested(NestedModel(ChildEntity), many=True)\n\n def __init__(self, name: str, children: List[ChildEntity]):\n self.children = children\n self.name = name\n\n\n``Self Referencing Model:``\n\n.. code-block:: python\n\n class Employee(Model):\n name = fields.String()\n # Use SelfReferencingModel to define self-referencing relationships\n subordinates = fields.Nested(SelfReferencingModel('Employee'), many=True, allow_none=True)\n\n def __init__(self, name: str, subordinates: List['Employee'] = None):\n self.subordinates = subordinates\n self.name = name", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://gitlab.com/py-ddd/toastedmarshmallow-models", "keywords": "serialization", "license": "apache2", "maintainer": "", "maintainer_email": "", "name": "toastedmarshmallow-models", "package_url": "https://pypi.org/project/toastedmarshmallow-models/", "platform": "", "project_url": "https://pypi.org/project/toastedmarshmallow-models/", "project_urls": { "Homepage": "https://gitlab.com/py-ddd/toastedmarshmallow-models" }, "release_url": "https://pypi.org/project/toastedmarshmallow-models/1.0.4/", "requires_dist": null, "requires_python": "", "summary": "Class models with validation and serialization ", "version": "1.0.4" }, "last_serial": 3732736, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "479fa56d985cdae7be8c16a1f7cb73ce", "sha256": "7ed8268b5ef585f218ac5670112e22c4155d99dd2fb7c923a38801cd9a182aed" }, "downloads": -1, "filename": "toastedmarshmallow-models-1.0.0.tar.gz", "has_sig": false, "md5_digest": "479fa56d985cdae7be8c16a1f7cb73ce", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3483, "upload_time": "2018-03-23T20:31:34", "url": "https://files.pythonhosted.org/packages/da/f3/d09063610b2299533ab01b3d87650c686450af5cc46a5088cd44c7a83812/toastedmarshmallow-models-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "a0696491f7a5d9547e996b49ab337586", "sha256": "642808e59709a70e87d2130f55ca86db9d4359c0a42b0d5517e79ef8e7ded802" }, "downloads": -1, "filename": "toastedmarshmallow-models-1.0.1.tar.gz", "has_sig": false, "md5_digest": "a0696491f7a5d9547e996b49ab337586", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3539, "upload_time": "2018-03-30T20:39:57", "url": "https://files.pythonhosted.org/packages/bd/72/f1330a490fe1f379467c1dc15d0d191ee8a973cef581509305dd5ce668e4/toastedmarshmallow-models-1.0.1.tar.gz" } ], "1.0.2": [ { "comment_text": "", "digests": { "md5": "b8f066dd8d3a7ff86879af2aad6a5b6d", "sha256": "76d5a2efa6b113e1491c1aeb9dbc72bbef6de0d0c12c1e81dc622609685434de" }, "downloads": -1, "filename": "toastedmarshmallow-models-1.0.2.tar.gz", "has_sig": false, "md5_digest": "b8f066dd8d3a7ff86879af2aad6a5b6d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3523, "upload_time": "2018-03-30T21:10:44", "url": "https://files.pythonhosted.org/packages/cb/b3/c7935d2a0aee8739e45f54dbdd5a02f209a8c49ecc8c3ee2aaf525f555d0/toastedmarshmallow-models-1.0.2.tar.gz" } ], "1.0.3": [ { "comment_text": "", "digests": { "md5": "57dbabf7b25fb0d15fa1a7727efe2721", "sha256": "d743601aff21ab09b4229383e3a54e11b75421e92f3e8999d15172983e9b280f" }, "downloads": -1, "filename": "toastedmarshmallow-models-1.0.3.tar.gz", "has_sig": false, "md5_digest": "57dbabf7b25fb0d15fa1a7727efe2721", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3543, "upload_time": "2018-04-02T08:32:34", "url": "https://files.pythonhosted.org/packages/8c/1c/9f5280322cb34aa932b72de521a62d3822824d4ebfcc80e3a49d882702b0/toastedmarshmallow-models-1.0.3.tar.gz" } ], "1.0.4": [ { "comment_text": "", "digests": { "md5": "d74d5ad70b02679001e51584eade72bc", "sha256": "0cc66724d10a52a5a178d1321a767c190412a6de703d6fee0bc4cc6f05f7f01b" }, "downloads": -1, "filename": "toastedmarshmallow-models-1.0.4.tar.gz", "has_sig": false, "md5_digest": "d74d5ad70b02679001e51584eade72bc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3586, "upload_time": "2018-04-04T06:55:11", "url": "https://files.pythonhosted.org/packages/a9/1f/ca3bf352e5e07c44b90cd7cd0a0416c947a2dadeb7559c9dd572d27af2b3/toastedmarshmallow-models-1.0.4.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "d74d5ad70b02679001e51584eade72bc", "sha256": "0cc66724d10a52a5a178d1321a767c190412a6de703d6fee0bc4cc6f05f7f01b" }, "downloads": -1, "filename": "toastedmarshmallow-models-1.0.4.tar.gz", "has_sig": false, "md5_digest": "d74d5ad70b02679001e51584eade72bc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3586, "upload_time": "2018-04-04T06:55:11", "url": "https://files.pythonhosted.org/packages/a9/1f/ca3bf352e5e07c44b90cd7cd0a0416c947a2dadeb7559c9dd572d27af2b3/toastedmarshmallow-models-1.0.4.tar.gz" } ] }