Skip to main content

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.

License https://img.shields.io/pypi/v/odin.svg?style=flat Travis CI Status Coveralls Requirements Status Gitter.im

Highlights

  • Class based declarative style

  • Fields for building composite resources

  • Field and Resource level validation

  • Mapping between resources or extended to other object types (eg Django Models)

  • Easy extension to support custom fields

  • Python 2.7+, Python 3.3+ 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.

Upcoming features

In development

  • XML Codec (export completed)

  • Complete documentation, this will pretty much always be here.

  • Improvements for CSV Codec (writing, reading multi resource CSV’s)

  • RESTful interface with support for Flask and Django see (see baldr)

  • Integration with other libraries (ie Django Models/Forms) (see baldr)

Planning

  • YAML codec

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

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, 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 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 files for odin 0.7.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for odin 0.7.1
File Size Uploaded
odin-0.7.1.tar.gz 66.6 kB Details

Release files / odin-0.7.1.tar.gz

Download URL odin-0.7.1.tar.gz
Size 66.6 kB
Tags Source
SHA-256 checksum
How to use checksums
247e106691cfab9e57d6497877c17d851682e8ee139a486766fe3fad1507455c
BLAKE2b-256 checksum
How to use checksums
8ea24736ab96bda6603663ccd12db7b26942c0f4b440937fc43f79c3659e68cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

2.11

2 release files

2.10

2 release files

2.9.0

2 release files

2.8.1

2 release files

2.8

2 release files

2.6

2 release files

2.5

2 release files

2.4

2 release files

2.3.1

2 release files

2.3

2 release files

2.2

2 release files

2.1

2 release files

2.0

2 release files

1.8.1

2 release files

1.8.0

2 release files

1.7.3

2 release files

1.7.2

2 release files

1.7.1

2 release files

1.7.0

2 release files

1.6.2

2 release files

1.6.1

2 release files

1.6.0

2 release files

1.5.2

2 release files

1.5.1

2 release files

1.4.0

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.1

3 release files

1.1

2 release files

1.0

2 release files

0.10

2 release files

0.9

1 release file

0.8.2

2 release files

0.8.1

2 release files

0.8

1 release file

This release

0.7.1 This release

1 release file

0.7

1 release file

0.6

1 release file

0.5.7.1

1 release file

0.5.6

1 release file

0.5.5

1 release file

0.5.2

1 release file

0.5

1 release file

0.4.3.2

1 release file

0.4.3.1

1 release file

0.4.3

1 release file

0.4.2

1 release file

0.4.1.1

1 release file

0.4.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page