Hi Matthias, yes that makes perfect sense. Also, I just noticed this page
<https://traitlets.readthedocs.io/en/latest/config.html#module-traitlets.config>,
which has a really good explanation. I don't know why I couldn't find that
before when I was searching. Thanks again!
On Monday, September 26, 2016 at 10:00:40 AM UTC-7, Matthias Bussonnier
wrote:
>
> Hi Steve,
>
> Quickly handwaved:
>
> ```
> from traitlets import Configurable, Unicode
>
>
> class MyCustomContentManager(Configurable):
>
>
>
> # the class attribute will be AutoMagically be made a instance one
> and accessible via self.parameter.
> parameter = Unicode('default', config=True, help='Frobulate
> parameter as Unicode from the command line or config files.')
>
> def __init__(self, ..., parent=None, config=None):
> super().__init__(...,parent=parent, config=config) # important
> ...
> ```
>
>
> You can set the value of parameter with
> `c.MyCustomContentManager.parameter = 'Whatever'` in any config file.
>
> This pattern is in many places of our codebase[1] and uses metaclasses.
>
> If your content manager inherit from ours , then
> `c.ContentManager.parameter = 'Whatever'` should work as well.
>
> Does that make some sens ? There is a bit more magic involved if you
> want advanced features, but I guess that might be already a lot to
> digest.
>
> Cheers,
> --
> M
>
>
> [1]:
> https://github.com/jupyter/notebook/blob/master/notebook/services/contents/manager.py#L65-L95
>
>
> On Mon, Sep 26, 2016 at 9:47 AM, Steven Anton <[email protected]
> <javascript:>> wrote:
> > Hi everyone,
> >
> > I have a custom ContentsManager class that I'd like to configure using
> the
> > standard Jupyter tools. In particular, I'm looking for something along
> the
> > lines of adding a line like "c.MyContentsManager.parameter = 'value'" to
> the
> > jupyter_notebook_config.py and reading that parameter in the custom
> > ContentsManager. I'm hoping this is an easy task, but I can't seem to
> find
> > the relevant functions in the jupyter source code. Maybe something like:
> >
> > # source code for the custom ContentsManager
> >
> > from notebook.services.config import ConfigManager
> >
> > cm = ConfigManager()
> >
> > cm.get("MyContentsManager").get("parameter", "default")
> >
> > Does anyone have ideas on how to accomplish this?
> >
> > Thanks so much!
> > Steve
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups
> > "Project Jupyter" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> an
> > email to [email protected] <javascript:>.
> > To post to this group, send email to [email protected]
> <javascript:>.
> > To view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/jupyter/193be8d9-3321-4dca-b058-6c9ce266355b%40googlegroups.com.
>
>
> > For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups
"Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jupyter/244fcb2c-574a-4ad1-8e43-29f4bb19e4bf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.