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.6.tar.gz (22.7 kB view hashes)

Uploaded source

Built Distribution

m9g-0.0.6-py2.py3-none-any.whl (21.1 kB view hashes)

Uploaded py2 py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page