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

Inject context dict to plugin if it has a set_context method #294

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

db4y
Copy link

@db4y db4y commented Apr 21, 2021

Hi @codingjoe

About #290 I came up with this.

If you need to inject something to your plugin you would

  1. subclass the view and create a get_plugin_context(plugin_name) in it. In that method you can inject what you need. Since the plugin name is passed as an argument, you can customize what you inject for each plugin.
  2. in your plugin you can now access self.context and override the set_context() method if needed.

What do you think?

Copy link
Collaborator

@codingjoe codingjoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @db4y,

this looks promising. I just had a first glance to be able to leave you simple architecture feedback. I understand the context approach, but that's probably more than is needed here. Maybe we keep it simple and just add the request as an argument to run_check.
I don't mind a breaking release. It's easily fixed, should people use their custom checks.

Best,
Joe

@db4y
Copy link
Author

db4y commented Apr 21, 2021

I get your point @codingjoe I thought the context solution would cover hypothetical future needs and allow to pass any object that the plugin may need from the view.

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

Successfully merging this pull request may close these issues.

2 participants