Custom handlers #5190

Closed
wants to merge 2 commits into
from

Conversation

Projects
None yet
2 participants
Contributor

dalejung commented Feb 21, 2014

Allow custom handlers via ipython config.

WIP. Appears my editor is fixing whitespace. Gotta clear that up.

juhasch referenced this pull request in ipython-contrib/jupyter_contrib_nbextensions Feb 23, 2014

Closed

Save pasted images to file instead of base64 blob? #43

Contributor

dalejung commented Feb 26, 2014

Example:

c.NotebookApp.webapp_settings = {}
c.NotebookApp.webapp_settings['custom_handlers'] = ['nbx.handlers']
Owner

ellisonbg commented Mar 1, 2014

I have very mixed feelings about adding this capability. The problem is that it is a slippery slope - by allowing custom handlers, we will have to add a flurry of other extension points to allow these custom handlers to do whatever they want. In the end, notebookapp.py would end up being a fully customizable web app framework. I am -1 on that trajectory.

The simple answer is to just say: if you want other logic/handlers you are writing a custom web app. Just make a copy of notebookapp.py and customize it to your hearts content. You can even import that classes defined in it, subclass methods, etc. I would be +1 on refactoring the classes/methods in notebookapp.py to make this type of customization easier.

Can you explore this alternate route?

Contributor

dalejung commented Mar 1, 2014

That is the path I went down already. https://github.com/dalejung/ipycli. I'm not apprehensive of going off the reservation. However, it's easier to test and share feature enhancements via plugins.

I could firewall the custom handler behind a /custom if you're worried about clashing with future api changes.

Contributor

dalejung commented Mar 1, 2014

As for a usecase. ipycli has a standalone handler that allows objects within a kernel to essentially serve a webpage. The uri was /standalone/{notebook_id}/{object_name}/{object_attr}. I used to do analysis in a notebook and then link out to a full page interactive chart using d3.js.

http://nbviewer.ipython.org/gist/dalejung/8674170

I think this PR, alongside #5169, is all I need to port over.

@dalejung dalejung added a commit to dalejung/nbx that referenced this pull request Mar 3, 2014

@dalejung dalejung figured out a way to enable ipython/ipython#5190
without changing ipython
8363037
Owner

ellisonbg commented Mar 6, 2014

We talked today at the dev meeting about this idea. We feel that it is better to encourage subclassing of the notebookapp in cases like this. This will provide much more flexibility for you and will allow to to keep our core code more simple and maintainable. Because of this, I am going to close this PR.

However, we also decided that we want to improve the design of the notebookapp to make the API more stable and easier to subclass. We encourage you to look at your code in this light. Are there things we can do to make it easier for you to subclass? If so, maybe open an issue describing what needs to be done. We can move to implementation from there.

ellisonbg closed this Mar 6, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment