[IPython-dev] Embedding the HTML notebook

Brian Granger ellisonbg at gmail.com
Mon Apr 9 18:21:23 EDT 2012


On Wed, Apr 4, 2012 at 3:46 PM, Matthew Turk <matthewturk at gmail.com> wrote:
> 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?

Right now the answer is no.  We are currently using tornado as the
templating library and it doesn't support loading templates from
multiple directories.  However, we have plans to switch over the
jinja2, which supports this fine.  As part of that change we will also
be reorganizing the templates and javascript code to make it much
easier for people to customize things and reuse things as part of
their own web apps.  This is relatively high on my list of things
todo, but still might take a while to get to.  Part of the problem is
that this stuff is significant enough that it has to wait until after
the 0.13.

> 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,

Yes, and this is exactly the weakness of tornado's template renderer
and why we are moving away from it.

>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?

Today there is not easy way of doing this.  You would basically have
to duplicate everything.  After the refactoring, it should be much

>  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.

Unfortunately, for now I think the best answer is to wait.  We will
try our best to get to this ASAP though.



> -Matt
> _______________________________________________
> 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