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

Pass config to hook handlers whenever possible #32

Open
Tracked by #123
kdmccormick opened this issue Jun 24, 2022 · 0 comments
Open
Tracked by #123

Pass config to hook handlers whenever possible #32

kdmccormick opened this issue Jun 24, 2022 · 0 comments
Labels
enhancement Relates to new features or improvements to existing features tutor Requires a change to Tutor

Comments

@kdmccormick
Copy link
Member

Context

When reacting to an action or adding to a filter, plugin authors may want to look into the Tutor configuration dictionary. Some actions and filters pass their handlers config as an argument, others don't.

For those hooks that don't pass config, plugin authors could still load the config dictionary themselves in a hacky way:

from tutor import hooks, config

@hooks.SOME_ACTION.add()
def handle_some_action(...)
    root = ... # do some hackery to determine project root
    cfg = config.load_config(root)
    # then, handle action based on `cfg`

but this is clearly not something we want plugin authors resorting to.

I can't think of a good heuristic for whether or not a hook should pass config as an argument... so my gut feeling is that we should pass config as an argument to every single hook, in case plugin authors find it useful. (That being said, there are some hooks, like CONFIG_DEFAULTS, that we cannot possibly pass config to because the hook itself is used to build config.)

My proposal

In the interest of making the Plugin API as powerful as possible (without sacrificing our ability to maintain Tutor) , I propose that the config argument is passed to every hook, except for those hooks which are run before config is available.

Acceptance Criteria

TBD

@kdmccormick kdmccormick added the enhancement Relates to new features or improvements to existing features label Jun 24, 2022
@kdmccormick kdmccormick transferred this issue from openedx-unsupported/wg-developer-experience Mar 28, 2024
@kdmccormick kdmccormick added the tutor Requires a change to Tutor label Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Relates to new features or improvements to existing features tutor Requires a change to Tutor
Projects
No open projects
Development

No branches or pull requests

1 participant