This is a combination of 10 commits.
Enable widget instanciation from front-end.
Address @minrk 's review comments.
Make API that allows users to persist widget state easily.
Added support for view persistence
Started adding support for model persistence.
Half way there!
Finished persistence API.
Move persistence code into the widget framework.
Fin.
Bug fixes
From widget Trello: version numbers for widget models;
when reloaded, will give the widget a chance to do
something intelligent or fail (by default) if the
version number doesn't match.
Comparison between arbitrary python objects can get crazy, whereas we really
only care about if the JSON state we are syncing is different. So with this change,
we store and check against the JSON state.
Sometimes for consistency or efficiency purposes, it makes sense to update
a group of properties all at once. This context manager makes this possible.
We also fix a bug where send_state was not passing the key on to get_state.
Instead of automagically instantiating a comm when it is accessed, require a call to open(). This makes the comm attribute much less magical, and hopefully more understandable.
This will immediately create a model on the javascript side when a widget is created. This means that, for example, a widget that only interacts with its model can work without "displaying" it.
This seems to make it easiest to select the top-level element. An alternative is to use special syntax for top-level elements, like in https://github.com/ipython/ipython/pull/6185
This will be followed up by other fixes that let the user set specific common properties of different elements.
This change also adds the .addBack() call, which means that nonempty selectors now apply to this.$el and its descendants, rather than just the descendants of this.$el.