app.config.get('section', 'value')
and the value doesn't exist, I get a configparser.NoOptionError
, yet I cannot handle this exception since I'm not sure which module it's declared in. I tried searching for it in the cement source code but I couldn't find the module which declares the error. I would like to know how to catch this error or if I should just set all the default app.config
values before I parse a config file.
yourapp.whatever.controllers.LiteController
… and then int he plugin’s load()
function you would app.handler.register(AdvancedController, force=True)
which forces it to register overtop of the LiteController
(of the same label)
/etc/<project_name>/<project_name>.conf
self.app.config.get('section', 'option')
in the _setup
function of the plugin but is there a way retrieve that information without invoking app
?self.app.config.get
(understandable) you could create a shortcut like using get_section_dict
self.config = self.app.config.get_section_dict(‘my_plugin’)
… then just use self.config[‘my_key’]
through out your plugin
app
is only available in the _setup
method.
app
is passed to the _setup()
method … because that is called when the plugin is instantiated during app.setup()
. You should set self.app = app
in _setup()
.. or if you subclass from cement.core.handler.CementHandler
just make sure you super()
in _setup()
and it does that
app.setup()
you can access self.app
anywhere in the plugin class