Integrating Ember with Pyramid


#1

I need help integrating emberjs with pyramid. I’ve just finished the basic tutorial and would like to try it out further with doing a single page application with pyramid + pgsql (CRUD) and with pyramid just returning json results.

Some questions that I have are:

  1. Where do I put the emberjs in my Pyramid project folder.

  2. For retrieving and sending json data, would this link be the appropriate api to follow ( http://emberjs.com/api/data/classes/DS.JSONAPIAdapter.html ), as I saw many conflicting discussions about ember-data that basically paints ember-data in a negative way.

  3. What is the difference between http://emberjs.com/api/data/classes/DS.RESTAdapter.html and http://emberjs.com/api/data/classes/DS.JSONAPIAdapter.html?

PS: I have no experience with js mvc except js tool-kits like jQuery and react-native.

Thanks for taking the time to answer simple questions like these.


#2

Just a few hints - without any knowledge about Pyramid:

During development use ember-cli’s proxy-parameter to redirect api-requests to your Pyramid-Backend.
See http://ember-cli.com/user-guide/#using-ember-cli
and http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/startup.html#startup

Terminal 1 (cd to your pyramid-app directory):
$ pserve development.ini
(or however it is started, notice the port it is being served)

Terminal 2 (cd to your ember-app directory):
$ ember server --proxy http://localhost:6543
(6543 is an example, use the port of your currently running pyramid-app)

Then open http://localhost:4200 to see your ember-app. All non-static-content (e.g. calls to api) will be redirected to your running pyramid-server.

If you want to go live, create a build of your Ember-App (again, see http://ember-cli.com/user-guide/#using-ember-cli) and put it to the static-assets-location that you configured in your pyramid-app.

=> Static Assets with Pyramid:
http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/assets.html#static-assets-section

=> JSON with Pyramid:
http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/renderers.html#json-renderer


Regarding adapters: Each adapter supports a different JSON-format.
The RESTAdapter is a very basic adapter and brings its own conventions regarding the json-format (see the docs).
The JSONAPIAdapter is build around the JSON-API standard, see http://jsonapi.org for docs and examples. This is what most people want.


Hope this helps!

#3

Thanks! That really helps massively