Twisted is a networking module for Python. The SAGE Notebook server will be converted to a twisted "web2" web server. This conversion will most likely be undertaken by Tom Boothby or Alex Clemesha.
Here is one idea from Brian Granger <[email protected]>:
We (the IPython team - myself, Fernando and Min) and been thinking some about an IPython notebook interface. We have two different prtototypes (ones based on wx and one based on twisted/nevow). While we are mostly focusing on the low level architecture right now we do plan on having an officially supported web based IPython notebook. Here are some of our current thoughts:
1. If you want to be able to deploy the notebook using a variety of web servers (apache, web2, etc.), you should definitely look at the WSGI spec (http://www.python.org/dev/peps/pep-0333/) and pylons/paste.
2. Only write the actual web app using twisted web2 if you really need access to the low level details. In our case, we need to use Twisted web2 for the notebook as the "notebook server" also needs to maintain a persistent connection (using Perspective Broker or another protocol) to the IPython engines. Without twisted we simply couldn't do this. But if your web app is a standalone process that doesn't need to use twisted for other reasons, there is no reason to actually build your web app using low level twisted web2 resources.
3. Our current design idea looks something like the following:
- Use low level twisted web2 to expose the ipython controller as a REST style web service. For this we will basically adapt our controller service to the http protocol using web2 resources.
- Write the actual web app using pylons. Pylons is a nice emerging web app (anti-)framework that is built around WSGI components. We have used Pylons extensively at our company for very dynamic web apps (ones that are even more complex than a notebook) and have been very happy. Because your pylons app is just a WSGI component, you can run it in the same process as the other web2 resources.
- The notebook web app then makes AJAX web services calls to the web2 resources.
The thing that is nice about this approach is that we can deploy the entire thing using twisted, but we get to write the web app using a higher level tool than twisted. Also, if we want to deploy the web app using a different web server (apache or cherrypy) we can do that because it conforms to the WSGI spec. We also looked at Turbogears and Django, but they didn't play with twisted as well and were a bit to constraining in terms of the types of model classes you could use.