Skip to main content

Define models for communication between components, handling MarshallinG (m9g)

Project description

Build Status

m9g : Define models for communication between components, handling MarshallinG (m9g)

Usage

>>> import m9g
>>> class Book(m9g.Model):
...     id = m9g.IntField(pk=True)
...     author = m9g.StringField()
...
>>> book = Book(id=1, author="Hemingway")
>>> book.serialize()  # JSON as default
'{"id": 1, "author": "Hemingway"}'

Complex types

import datetime

>>> class Author(m9g.Model):
...     id = m9g.IntField(pk=True)
...     authored_books = m9g.ListField(
...             m9g.StringField()
...     )
...     birth_date = m9g.DateField()
...
>>> author = Author(
...     id=1,
...     authored_books=[
...             "The Torrents of Spring",
...             "The Sun Also Raises",
...             "A Farewell To Arms"
...     ],
...     birth_date = datetime.date(
...             year=1899,
...             month=7,
...             day=21
...     )
... )
>>> author.serialize()
'{"id": 1, "authored_books": ["The Torrents of Spring", "The Sun Also Raises", "A Farewell To Arms"], "birth_date": "1899-07-21"}'

Contributing

Run tests for python 2.7 / 3.6

    tox

Run one-off test

    tox -- tests/<test_file>.py::<test_name>

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

m9g-0.0.0.tar.gz (21.0 kB view hashes)

Uploaded Source

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