[IPython-dev] widget models caching the view

Jason Grout jason-sage at creativetrax.com
Sat Feb 22 01:18:08 EST 2014


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?

Thanks,

Jason



More information about the IPython-dev mailing list