[IPython-dev] widget models caching the view

Jason Grout jason-sage at creativetrax.com
Sat Feb 22 10:35:11 EST 2014


On 2/22/14 12:18 AM, Jason Grout wrote:
> Hi all,
>
> Right now, in the new widget system, when a view is created of a model,
> the view is added to the model's view list here:
>
> https://github.com/ipython/ipython/blob/master/IPython/html/static/notebook/js/widgetmanager.js#L123
>
> Since that code was written, we've settled on a more complete
> understanding of the roles of views, models, and the python traits
> classes.  It seems that it would be better now to have a single view
> cached with the model rather than a list of views, and if create_view is
> called on a model that already has a view created, the already-created
> view should be returned, rather than creating a new view.  In other
> words, it seems that the create_view function in the widget manager should:
>
> 1. check to see if model.view is set.  If it is, return it
>
> 2. If model.view is not set, construct and return it, caching the new
> view in the model.view attribute.
>
> Brian, Jonathan, others?  What do you think?

I've submitted a PR for this change: 
https://github.com/ipython/ipython/pull/5198

Thanks,

Jason





More information about the IPython-dev mailing list