[IPython-dev] Efficient way to render Javascripts

Jason Moore moorepants at gmail.com
Sat Jun 15 12:23:04 EDT 2013


Brian,

So it seems that for us to get some data from a python object into our
javascript, we write the data to file on the fly so that a js cell can pull
it in from the filesystem or we hard code the data into the js string. Is
that the way it should be done with the current setup?

So we'd like the functionality for GET/POST in the notebook for our
project. And I have one full time student that starts this week. What would
be the best way for us to contribute some patches to jumpstart this on the
ipython side?



Jason
moorepants.info
+01 530-601-9791


On Sat, Jun 15, 2013 at 9:02 AM, Brian Granger <ellisonbg at gmail.com> wrote:

> Right now it does not have any easy way of doing that.  For now you
> will have to encode your data into the call to kernel.execute, which
> is a completely pain. That is exactly what we will be tackling later
> in the summer...
>
> Cheers,
>
> Brian
>
> On Sat, Jun 15, 2013 at 8:54 AM, Jason Moore <moorepants at gmail.com> wrote:
> > Brian,
> >
> > In IPython, is there a standard mechanism to pass data from the client to
> > the server? We'd like to make some python calls that generate a data
> > stucture, jsonify it and then make it available to the javascript that is
> > running in a cell via a GET request. I assume the kernel architecture has
> > this in place?
> >
> >
> > Jason
> > moorepants.info
> > +01 530-601-9791
> >
> >
> > On Sat, Jun 15, 2013 at 8:14 AM, Brian Granger <ellisonbg at gmail.com>
> wrote:
> >>
> >> Right now (today) the best way is to use the Javascript object along
> >> with the display function.  However, starting in late summer we will
> >> be improving this API so it may change some, but all for the better...
> >>
> >> Cheers,
> >>
> >> Brian
> >>
> >> On Fri, Jun 14, 2013 at 11:33 PM, TARUN GABA <tarun.gaba7 at gmail.com>
> >> wrote:
> >> > Hi,
> >> >
> >> > I am wondering on what method would be more efficient to serve
> >> > Javascripts on IPython notebooks
> >> >
> >> > I need to visualize/simulate multibody dynamics, and there are two
> >> > methods which are in my mind.
> >> > The rough API of the project is being formed at ..
> >> >
> >> > http://pydy.org/visualization
> >> >
> >> > the two methods are:
> >> > 1) Via http requests:
> >> >
> >> >   on calling something like ..
> >> >
> >> > myobject.visualize(numerical_data)
> >> >
> >> > The browser sends a POST request to the kernel, and python methods
> >> > send a POST request to the required javascripts alongwith POST
> >> > parameters as the numerical data required for visualization, most
> >> > likely a 4*4 transformation matrix, and shape information.
> >> > the Javascripts recieves the post and then it is displayed in the
> >> > IPython output cell.
> >> >
> >> > 2) Another method can be to make Javascript objects and save them as
> >> > text in the classes,
> >> > something like ..
> >> >
> >> > def MyClass():
> >> >
> >> >     def __init__(relevant,args):
> >> >         self.js_data = ''' A call to the Javascript functions,
> >> > alongwith arguments..
> >> >                              var myobject =
> >> > Shape_creating_function(%s)'''%(args)
> >> >
> >> > and then on calling ..
> >> > MyClass.visualize()
> >> >
> >> > from IPython notebook, first calling all the required
> >> > javascripts(files) via publish_javascript()/publish_html() display
> >> > methods and then
> >> >
> >> > display(Javascript(MyClass.js_data))
> >> >
> >> > Which of these would be more feasible and efficient..
> >> > _______________________________________________
> >> > 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
> >> _______________________________________________
> >> IPython-dev mailing list
> >> IPython-dev at scipy.org
> >> http://mail.scipy.org/mailman/listinfo/ipython-dev
> >
> >
> >
> > _______________________________________________
> > 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
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20130615/31eef50d/attachment.html>


More information about the IPython-dev mailing list