balanced / balog

Balanced event logging schema and library
Other
0 stars 8 forks source link

How to serialize objects #18

Open mjallday opened 9 years ago

mjallday commented 9 years ago

Colander does not support serializing an object to its json representation

Maybe pez, schematics or marshmallow

mahmoudimus commented 9 years ago

My vote is for schematics.

mjallday commented 9 years ago

Looks like schematics would require a little work.

https://github.com/schematics/schematics/blob/development/schematics/transforms.py#L58

it wants everything to inherit from a base class, but what you actually want is a library that can map from one set of objects to another. if you look at how the sqlalchemy plugin works it's quite gross.

class Person(Base):

    __tablename__ = 'person'

    _id = Column('id', Integer, primary_key=True)
    _name = Column('name', String(50))

    id = IntType(default=1)
    name = StringType()