[IPython-dev] Embedding the HTML notebook

Matthew Turk matthewturk@gmail....
Wed Apr 4 17:46:16 CDT 2012

Hi there,

After something of a protracted discussion on Fernando's Google+
stream about embedding the IPython notebook, I started digging into
the notebook manager code.  As something of an introduction, I'm
relatively new to this aspect of IPython, but I work on a project (
yt-project.org ) that currently has a web GUI with a
(execution-blocking, much less fancy, somewhat clunky) web notebook.
On top of this we've built a number of display widgets, which really
are what we spend the most time on and what we're most proud of, but
more importantly they're what we want to focus our development energy
on moving forward.

Anyway, this is a long way around of saying we're looking really hard
at ditching our current cell-REPL system and instead building in the
IPython notebook, since it's awesome.  I'm trying to come up to speed
with how the web notebook works, and I have a couple questions about
the broad feasibility.

To embed as is, it looks like (as shown with NINJA-ide) one can embed
an iframe to link to a running notebook server.  But rather than doing
something precisely like that, since we're looking at providing
additional items such as widgets (although Fernando mentioned that
interoperation with callbacks is still underway) is it possible to
extend the templates from the API?

Inside IPython/frontend/html/handlers.py, the render methods are code
with calls to specific template names, which then render out HTML
templates from a path that can be overridden with settings_override.
I *think* from reading the tornado docs that template_path has to be a
single string and not an iterable of strings, and the handlers
themselves are enumerated as classes in the NotebookWebApplication
handlers.  It was when I got this deep that I started to wonder if
perhaps there was an obvious, more straightforward way that I was
missing; if not, I'm definitely willing to do what I can to dive in
and contribute, if embedding is something of interest to the
community, too.

If we take as a given that an IPython engine is currently running,
what would the best route toward embedding a view -- that doesn't
fully duplicate the contents of static/ and templates/ -- into that
engine?  Would prepending an additional path to the base_project_url
work, so that any calls to/from the engine would require that
base_project_url?  And then, post-instantiation, appending new
handlers to the NotebookWebApplication, for the "embedding" app's
templates, which perhaps have to be rendered from strings?

Any ideas would be greatly appreciated, and again, thanks for all your
hard work on IPython.


More information about the IPython-dev mailing list