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.6.0.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

marshmallow_mongoengine-0.6.0-py2.py3-none-any.whl (13.8 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

File hashes

Hashes for marshmallow-mongoengine-0.6.0.tar.gz
Algorithm Hash digest
SHA256 142b1ec104b14eb3c214153b7b8578778e4cc122a8644b5494c72672872e3a8c
MD5 6d147d58d3ba0457e760874745c73d6a
BLAKE2b-256 8ee31eee8f47fdb29d962caa7edf925639c459fcb7cf51e3875282856e043049

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for marshmallow_mongoengine-0.6.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 537cfac901297259319e328fc185a71e9e62ab5f4d262c407ce6da736491ca2f
MD5 869dd82b2108bd42fb221b56a1b03fb6
BLAKE2b-256 28d3c6f540869185e906004bfabd56c024588d4d7417df641b6fa6ddee8db820

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