13.07.2015 Views

Modern Web Applications with Flask and Backbone.js

Modern Web Applications with Flask and Backbone.js

Modern Web Applications with Flask and Backbone.js

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Two great tastes that tastegreat together!class Marshallable(Resource):method_decorators = (marshal_<strong>with</strong>(self.fields),)class Entity(Marshallable):def build_query(self):return self.model.querydef get(self, id):return self.build_query().get_or_404(id)class UserMixin(object):fields = {"username": String}model = models.Userclass User(UserMixin, Entity):passapi.add_resource(User, '/api/users/',endpoint='api_user')

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!