cpssd-students/steely

Move away from flat dir for plugins

Closed this issue · 10 comments

As Aaron mentioned in #109, it's getting infeasible.

byxor commented

I like this idea.

byxor commented

I wonder when this will happen. Eventually we'll hit a point where too many plugins have their own sub-modules and it'll make a lot of sense to do this.

I wonder when this will happen. Eventually we'll hit a point where too many plugins have their own sub-modules and it'll make a lot of sense to do this.

byxor commented

I wonder when this will happen. Eventually we'll hit a point where too many plugins have their own sub-modules and it'll make a lot of sense to do this.

while we're at this, we might as well think about plugin configs.

at the moment all plugin settings are in the main config.py eg. https://github.com/sentriz/steely/blob/master/steely/config.py.sample#L4-L16

this could be fixed by moving to yml and having config sections eg

email: dfsdfsdf
password: sdfsdf
admins:
  - sdfsdf
  - sdfsdf
plugins:
  flascnasc:
    host: adsdfsdf
    key: sdfsdfsdf

and then pass in the plugin's own settings into the plugins' main() along with message and the rest (or something nicer with a helper function the utilities module or something)

or if we do this plugin directory stuff, have a plugin specific config.yml in each plugins' directory. eg

plugins/
    lastfm/
        __init__.py # main plugin
        np.py
        history.py
        config.yml

it should be easy to get to the plugin's yaml from the plugin itself with relative imports

so what's better?

Centralised config > per-dir configs. It feels less nice and separated, but means you only have 1 place to look whenever you're setting up the project, or whenever something goes wrong, instead of ~30. yaml with config sections looks grand.

that makes sense
how would you go about giving each plugin its config object? passing it into the plugin's main() seems bad

A global plugin read-only dict with each plugin just querying CONFIG['np']['shortener_url'] or whatever seems fine? it's not a big enough deal to have a separation or making plugin configs private to other plugins or whatever

Closed by #215.