Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

Data-structure definition/validation/traversal, mapping and serialisation toolkit 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 objects (either a resource, or other python structures).

Odin also comes with built in serialisation tools for importing and exporting data from resources.

Highlights

  • Class based declarative style
  • Fields for building composite resources
  • Field and Resource level validation
  • Easy extension to support custom fields
  • Python 2.7 1, Python 2.7+, Python 3.5+ and PyPy 1 supported
  • Integration with Django (see baldr)
  • Support for documenting resources with Sphinx
  • Minimal dependencies (base functionality only requires six)

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

Use cases

  • Design, document and validate complex (and simple!) data structures
  • Convert structures to and from different formats such as JSON, YAML, MsgPack or CSV
  • Validate API inputs
  • Define message formats for communications protocols, like an RPC
  • Map API requests to ORM objects

Upcoming features

In development

  • XML Codec (export completed)
  • Complete documentation coverage
  • Improvements for CSV Codec (writing, reading multi resource CSV’s)
  • RESTful interface with support for Flask and Django
  • Integration with other libraries (ie Django Models/Forms)
  • Integration with SQLAlchemy

Requires

  • six

Optional

  • simplejson - Odin will use simplejson if it is available or fallback to the builtin json library
  • msgpack-python - To enable use of the msgpack codec
  • pyyaml - To enable use of the YAML codec

Contrib

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

Development

  • pytest - Testing
  • pytest-cov - Coverage reporting

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, indent=4)
{
    "$": "Book",
    "authors": [
        {
            "$": "Author",
            "name": "Iain M. Banks"
        }
    ],
    "genre": "Space Opera",
    "num_pages": 471,
    "publisher": {
        "$": "Publisher",
        "name": "Macmillan"
    },
    "title": "Consider Phlebas"
}

Authors

Tim Savage

Special Mention

I would like to acknowledge the strong influence on the design of Odin Resources 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 History

This version
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

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 Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
odin-1.2.0-py2.py3-none-any.whl (87.6 kB) Copy SHA256 Checksum SHA256 2.7 Wheel Nov 14, 2017
odin-1.2.0.tar.gz (274.7 kB) Copy SHA256 Checksum SHA256 Source Nov 14, 2017

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting