apiguy/flask-classy — pull request #72 by mattupstate (2014-12-17 18:29:35+00:00)
Title: Update flask_classy.py

Move the automatic response making code to the end of the view function proxy. This allows for more complex before/after processing. A hypothetical example:

```python
class MyResource(FlaskView):
serializers = {
'index': serialize_collection,
'default': serialize_resource,
}

def after_request(self, name, response):
serializer = self.serializers.get(name, self.serializers['default'])
return jsonify(serializer(response))

def index(self):
return Model.get_all()

def post(self):
return Model()

def get(self, resource_id):
return Model.get(resource_id)

def put(self, resource_id):
return Model.get(resource_id)
```