[IPython-dev] widget models caching the view

Brian Granger ellisonbg at gmail.com
Sat Feb 22 21:58:52 EST 2014

Hi, sorry, just catching up. I am confused. I don't see how this is
even possible. In browsers/DOM it is not possible to have a single DOM
element displayed in multiple places on the page. Isn't that what this
change tries to do? If it does work, I am guessing that it is broken -
surely the events won't fire properly when the view is on the page
multiple times.

Conceptually, I think we *do* want multiple views. Each view maps onto
one place in the page where the widget is displayed. Each of those
instances needs to be able to handle its own events, etc. For example,
only one instance of the view can have focus at a time or accept
keyboard input.

Am I missing something?

On Sat, Feb 22, 2014 at 7:35 AM, Jason Grout
<jason-sage at creativetrax.com> wrote:
> 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
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev

Brian E. Granger
Cal Poly State University, San Luis Obispo
bgranger at calpoly.edu and ellisonbg at gmail.com

More information about the IPython-dev mailing list