forked from malingshu/todolist
-
Notifications
You must be signed in to change notification settings - Fork 0
robmccreary/todolist
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Working demo: http://todos-rest-server.appspot.com/ The main difference between appengine-rest-server and Backbone's expectations for a rest server are that the objects are wrapped. So we need to change Model.parse() and Model.toJSON() as well as Collection.parse() For example, appengine-rest-server expects an object like this: {Todos: { content: 'Buy milk.', done: 'false', order: 1 } } Whereas Backbone deals expects models like this: { content: 'Buy milk.', done: 'false', order: 1 } When GETting a collection, appengine-rest-server gives back something like: { list: { Todos: [ {content: 'Buy milk', done: 'false', order: '1'}, {content: 'Buy eggs', done: 'true', order: '2'} ] } } We need to parse it to look like: [ {Todos: {content: 'Buy milk', done: 'false', order: '1'}, {Todos: {content: 'Buy eggs', done: 'true', order: '2'}, ] And there is one other case. When the collection has only one element, a GET returns without a list like this: {Todos: {content: 'Buy milk', done: 'false', order: '1'} So we need to wrap that single object in a list: [{Todos: {content: 'Buy milk', done: 'false', order: '1'}] Another issue is that everything comes back as a string from the server. For example {"done": false} is returned as {"done": "false"} So we need to explicitly convert them. This is done in the helper function: convertStringToTypes which is called in AppengineRestModel.parse() The attributes to convert have to be specified in AppengineRestModel.attrTypes
About
Backbone.js with Google App Engine
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published
Languages
- JavaScript 75.4%
- Python 24.6%