A simple and fast ORM/ODM/framework-agnostic Python object serialization library
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
avocato
benchmark
docs
requirements
tests
.codecov.yml
.coveragerc
.gitignore
.readthedocs.yml
.travis.yml
CHANGELOG.md
LICENSE
Makefile
README.rst
setup.cfg
setup.py

README.rst

avocato: simple and fast object serialization

avocato is a simple and fast ORM/framework-agnostic object serialization library for converting complex objects to and from simple Python datatypes.

Don't be scared if you're using an ORM/framework. It can easily be adapted to be used with any ORM/framework of your liking. Currently it supports Django ORM and peewee.

This library is heavily influenced by serpy.

Installation

$ pip install avocato

Documentation

Find documentation at avocato.rtfd.io

Example

import avocato

class Bar(object):
    patrick = 'star'


class Foo(object):
    over = 9000
    spongebob = 'squarepants'
    bar = Bar()


class BarSerializer(avocato.Serializer):
    patrick = avocato.StrField()


class FooSerializer(avocato.Serializer):
    over = avocato.IntField()
    spongebob = avocato.StrField()
    bar = BarSerializer()


foo = Foo()
FooSerializer(foo).data
# {'over': 9000, 'spongebob': 'squarepants', 'bar': {'patrick': 'star'}}