[IPython-dev] Passing information to a NotebookManager
Matthias BUSSONNIER
bussonniermatthias at gmail.com
Tue Jan 28 08:00:07 EST 2014
Le 28 janv. 2014 à 12:31, Konrad Hinsen a écrit :
> Creating a NotebookApp with a modified notebook manager is easy enough:
> just configure NotebookApp.notebook_manager_class. But I need additional
> information passed to my notebook manager. Since I don't control the
> creation of the notebook manager object, I need to find some other way.
>
> I tried to use the configuration system, setting configuration options
> at run time:
>
> from IPython.html.notebookapp import NotebookApp
You could create a config object (from IPython.config.loader import Config)
add pass it as the config kwarg to NotebookApp,
or at lead use NotebookApp.update_config methods.
>
> app = NotebookApp()
> app.config.NotebookApp.notebook_manager_class = 'activepapers.notebooks.ActivePapersNotebookManager'
> app.config.ActivePapersNotebookManager.active_paper_path = filename
> app.config.ActivePapersNotebookManager.may_write = True
> app.initialize(argv=[])
> app.start()
>
> In my class ActivePapersNotebookManager, I have
>
> class ActivePapersNotebookManager(NotebookManager):
>
> active_paper_path = Unicode(config=True)
> active_paper_may_write = Bool(config=True)
>
> followed by the code. This works fine for active_paper_path, but
> active_paper_may_write ends up being False.
>
> Questions:
>
> 1) Is this the right approach, or should I try something else entirely?
> 2) How can I debug the information transfer through the configuration system?
Usually anything that can have "Configurable" traits should accept a config object at creation time.
config object would bubble into IPython.config.configurable:Configurable where the magic happens.
Any traits like the one you use can have on_change or validate methods that will trigger when value change or are set.
--
M
>
> Thanks in advance,
> Konrad.
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
More information about the IPython-dev
mailing list