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

Uploaded Source

Built Distribution

marshmallow_mongoengine-0.7.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.7.0.tar.gz.

File metadata

File hashes

Hashes for marshmallow-mongoengine-0.7.0.tar.gz
Algorithm Hash digest
SHA256 f1bd35d6c2659dafd365d7958f6d3c522e3dfda7bb040efaf4d3de2113412a9c
MD5 009618fd5dc22d71fb54324a3f633d27
BLAKE2b-256 7a9d5afec56e24617e22e7d2b99b3c9526e74e406f118ba41bddc926f499ce83

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for marshmallow_mongoengine-0.7.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 00fa18ee22fabac0fdfac8f1cd4a7be81b4bae5219f59754e768a38f0ed773dd
MD5 2242695d49ee80593ac0a1a5494fcb1d
BLAKE2b-256 1dd1f7aa91e3754f6afda63b4a7e6b4bd271f180dc322531d459de4398db2e5e

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