Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move constants into config using get_configuration_template #380

Open
jayvdb opened this issue Nov 26, 2017 · 2 comments
Open

Move constants into config using get_configuration_template #380

jayvdb opened this issue Nov 26, 2017 · 2 comments

Comments

@jayvdb
Copy link
Member

jayvdb commented Nov 26, 2017

plugins/constants.py should be removed, replaced with config variables defined using get_configuration_template

see http://errbot.io/en/latest/user_guide/plugin_development/configuration.html

@jayvdb
Copy link
Member Author

jayvdb commented May 24, 2018

Note that I explored this problem a little bit for #413

I found that this meant that the plugin could only be configured using !config , and didnt have the ability to load settings from a global config.

It is critical that corobo starts up using preset values from a config file.

As a result I did the following as a bit of a workaround:

    def get_configuration_template(self):
        config = {
           'CROSSLINK_GITHUB_TOKEN': '',
           'CROSSLINK_GITLAB_TOKEN': '',
           'CROSSLINK_OPENHUB_TOKEN': '',
        }

        for key in config:
            if hasattr(self.bot_config, key):
                config[key] = getattr(self.bot_config, key)

        return config

    def _get_config(self, key):
        if self.config and key in self.config:
            return self.config[key]
        return getattr(self.bot_config, key, None)

We could put something similar into a super class for all our plugins, but it feels like this might be better as an improvement in errbot upstream.

@jayvdb
Copy link
Member Author

jayvdb commented Aug 5, 2018

plugins/constants.py contains

So after #577 is merged, this issue is only about searchdocs plugin.

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

No branches or pull requests

3 participants