Fast functional serializers
Project description
Strainer is a different take on serialization and validation in python. It utilizes a functional style over inheritance.
An example of Strainer, the example has been borrowed from Marshmallow
artist_serializer = create_serializer(
field('name')
)
album_schema = create_serializer(
field('title'),
field('release_date'),
child('artist', serializer=artist_serializer)
)
class Artist(object):
def __init__(self, name):
self.name = name
class Album(object):
def __init__(self, title, release_date, artist):
self.title = title
self.release_date = release_date
self.artist = artist
bowie = Artist(name='David Bowie')
album = Album(
artist=bowie,
title='Hunky Dory',
release_date=date(1971, 12, 17)
)
simple_data = album_schema.to_representation({}, album)
pprint.pprint(simple_data)
# {'artist': {'name': 'David Bowie'},
# 'release_date': datetime.date(1971, 12, 17),
# 'title': 'Hunky Dory'}
Installation
To install Strainer, simply:
$ pip install pystrainer
✨🍰✨
Satisfaction, guaranteed.
Release History
0.0.4 (2016-11-23)
Add some validators
0.0.1 (2016-11-23)
Birth
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pystrainer-0.0.4.tar.gz
(4.4 kB
view hashes)