[IPython-dev] Loading nbextension on widget instantiation

Thomas Kluyver takowl at gmail.com
Sun Jun 15 15:05:02 EDT 2014


I've been working on a turtle implementation using widgets (announcement to
come when it's a bit more polished). If I load the nbextension for the
widget view in my custom.js, it works, but I don't want to make novice
users fiddle with that. I can
display(Javascript('IPython.load_extensions(...)')), but if I do that just
before the widget is created, the async pixies don't get the extension
loaded in time, so the first widget doesn't show up. So the user has to run
a 'preparation' cell before the code they want to write, to give the
extension time to load.

One solution I can see is to allow specifying the name of an nbextension in
the widget class in the kernel. The frontend would ensure that that
extension was loaded before trying to instantiate its counterpart. This
would be roughly equivalent to specifying a Python object using its full
importable name. There are two levels where this could work:

1. The comm manager could load the extension before looking up target_name.
2. The widget manager could load the extension before looking up view_name.

1. seems more correct and powerful, though 2. might be easier to implement,
and would suffice for what I'm trying to do.

This shouldn't be a security concern at the moment, because you can only
create comms/widgets by running code in the kernel, but we'll need to be
careful with it once widget persistence is in place, so it can't execute
untrusted JS on load.

Thomas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20140615/b6aa7b3b/attachment.html>


More information about the IPython-dev mailing list