Skip to main content

Mongoengine integration with the marshmallow (de)serialization library

Project description

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

Description: .. image:: https://travis-ci.org/touilleMan/marshmallow-mongoengine.svg?branch=master
:target: https://travis-ci.org/touilleMan/marshmallow-mongoengine
:alt: Travis-CI

=======================
marshmallow-mongoengine
=======================

`Mongoengine <http://mongoengine.org>`_ integration with the `marshmallow <https://marshmallow.readthedocs.org/en/latest/>`_ (de)serialization library.

Declare your models
===================

.. code-block:: python

import mongoengine as me

class Author(me.Document):
id = me.IntField(primary_key=True, default=1)
name = me.StringField()
books = me.ListField(me.ReferenceField('Book'))

def __repr__(self):
return '<Author(name={self.name!r})>'.format(self=self)


class Book(me.Document):
title = me.StringField()

Generate marshmallow schemas
============================

.. code-block:: python

from marshmallow_mongoengine import ModelSchema

class AuthorSchema(ModelSchema):
class Meta:
model = Author

class BookSchema(ModelSchema):
class Meta:
model = Book

author_schema = AuthorSchema()

(De)serialize your data
=======================

.. code-block:: python

author = Author(name='Chuck Paluhniuk').save()
book = Book(title='Fight Club', author=author).save()

dump_data = author_schema.dump(author).data
# {'id': 1, 'name': 'Chuck Paluhniuk', 'books': ['5578726b7a58012298a5a7e2']}

author_schema.load(dump_data).data
# <Author(name='Chuck Paluhniuk')>

Get it now
==========
::

pip install -U marshmallow-mongoengine

License
=======

MIT licensed. See the bundled `LICENSE <https://github.com/touilleMan/marshmallow-mongoengine/blob/master/LICENSE>`_ file for more details.

Keywords: mongoengine marshmallow
Platform: UNKNOWN
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

marshmallow-mongoengine-0.3.0.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

marshmallow_mongoengine-0.3.0-py2.py3-none-any.whl (12.3 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file marshmallow-mongoengine-0.3.0.tar.gz.

File metadata

File hashes

Hashes for marshmallow-mongoengine-0.3.0.tar.gz
Algorithm Hash digest
SHA256 f457649c73ff2a8b48036b84d6c50792cd275f2f940afb51b413f37eb61e2717
MD5 4b41c5ef78bd855e0c3ae10896853908
BLAKE2b-256 df50297a6f13306955b68dae601c6e4177086925a96520e1063b125fc18c97b7

See more details on using hashes here.

File details

Details for the file marshmallow_mongoengine-0.3.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for marshmallow_mongoengine-0.3.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 b5810e00686402b975c5076ce447eff73c3b86e884f8c3d324b1d9e609eca7dc
MD5 b7490608af652974f42722d7da11442b
BLAKE2b-256 49d55355936d090fe8a163e69567599904a28064182c1750577519c7e794b53d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page