Skip to main content
Help improve PyPI by participating in a 5-minute user interface survey!

Object Data Mapping for Python

Project Description

Odin provides a declarative framework for defining resources (classes) and their relationships, validation of the fields that make up the resources and mapping between different resources or an object graph of resources.

The library then expands on the basic features this with serialisation tools importing and exporting data.

License https://pypip.in/v/odin/badge.png Travis CI Status Coveralls Requirements Status

Highlights

  • Class based declarative style
  • Fields for building composite resources
  • Field and Resource level validation
  • Resource to resource mapping
  • Easy extension to support custom fields
  • Python 2.7+, Python 3.2+ and PyPy 1 supported
  • Integration with Django (see baldr)

1 certain contrib items are not supported. Pint is not installable with PyPy.

Upcoming features

In development

  • Customisable generation of documentation of resources (for integration into Sphinx)
  • Complete documentation, this will pretty much always be here. The main sections are complete though!
  • Improved for CSV Codec (writing, reading multi resource CSV’s)
  • Improved mapping, automapping of DictAs and ListOf fields
  • RESTful interface with support for Flask and Django
  • XML Codec (export completed)

Planning

  • YAML codec
  • Integration with other libraries (ie Django Models/Forms)

Requires

  • six

Optional

  • simplejson - Odin will use simplejson if it is available or fallback to the builtin json library

Contrib

  • jinja2 >= 2.7 - For documentation generation
  • pint - Support for physical quantities using the Pint library.

Example

With definition:

import odin

class Author(odin.Resource):
    name = odin.StringField()

class Publisher(odin.Resource):
    name = odin.StringField()

class Book(odin.Resource):
    title = odin.StringField()
    authors = odin.ArrayOf(Author)
    publisher = odin.DictAs(Publisher)
    genre = odin.StringField()
    num_pages = odin.IntegerField()
>>> b = Book(
        title="Consider Phlebas",
        genre="Space Opera",
        publisher=Publisher(name="Macmillan"),
        num_pages=471
    )
>>> b.authors.append(Author(name="Iain M. Banks"))
>>> from odin.codecs import json_codec
>>> json_codec.dumps(b, pretty_print=True)
{
    "$": "Book",
    "authors": [
        {
            "$": "Author",
            "name": "Iain M. Banks"
        }
    ],
    "genre": "Space Opera",
    "num_pages": 471,
    "publisher": {
        "$": "Publisher",
        "name": "Macmillan"
    },
    "title": "Consider Phlebas"
}

Special Mention

I would like to acknowledge the strong influence on the design of Odin from the Django ORM and it’s notable contributor Malcolm Tredinnick. He was a valued colleague who’s untimely passing left a large void in our company and the wider community.

Release history Release notifications

History Node

1.4.0

History Node

1.3.0

History Node

1.2.0

History Node

1.1.1

History Node

1.1

History Node

1.0

History Node

0.10

History Node

0.9

History Node

0.8.2

History Node

0.8.1

History Node

0.8

History Node

0.7.1

History Node

0.7

History Node

0.6.0.1

History Node

0.6

History Node

0.5.7.1

History Node

0.5.6

History Node

0.5.5

History Node

0.5.2

History Node

0.5

History Node

0.4.3.2

History Node

0.4.3.1

This version
History Node

0.4.3

History Node

0.4.2

History Node

0.4.1.2

History Node

0.4.1.1

History Node

0.4.1

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
odin-0.4.3.tar.gz (24.7 kB) Copy SHA256 hash SHA256 Source None Feb 2, 2014

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page