OpenUpSA / pmgbilltracker

Bill Tracking Application for the Parliamentary Monitoring Group
Apache License 2.0
5 stars 2 forks source link

Serialisation + REST #3

Closed adieyal closed 10 years ago

adieyal commented 10 years ago

Instead of writing code from scratch - rather use best practices. For object serialisation, http://flask-restful.readthedocs.org/en/latest/ seems to be the standard solution for flash.

In general, serialisation code should not be tied to a particular model. Instead, you should use external serialisers so as to ensure that models only represent business logic and don't include any other confusing code. Also, external serialisers allow for more flexibility if you want different serialisations of the same model.

petrus-jvrensburg commented 10 years ago

We're only using a single endpoint in the API at the moment, so I thought it might be an overkill to use a dedicated API extension for that. I'm rather enjoying the fine-grained control over serialization. And I thought the model would be the best place to define that logic.

But let me know if you feel strongly about changing this approach.

petrus-jvrensburg commented 10 years ago

Serialization now happens in serializers.py.