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

Possible to tell which hook answered a call? #485

Open
simonw opened this issue Mar 5, 2024 · 1 comment
Open

Possible to tell which hook answered a call? #485

simonw opened this issue Mar 5, 2024 · 1 comment

Comments

@simonw
Copy link
Contributor

simonw commented Mar 5, 2024

I have some code that looks like this:

        opinions = []
        # Every plugin is consulted for their opinion
        for check in pm.hook.permission_allowed(
            datasette=self,
            actor=actor,
            action=action,
            resource=resource,
        ):
            check = await await_me_maybe(check)
            if check is not None:
                opinions.append(check)

        result = None
        # If any plugin said False it's false - the veto rule
        if any(not r for r in opinions):
            result = False
        elif any(r for r in opinions):
            # Otherwise, if any plugin said True it's true
            result = True

This is for a plugin-based permission model.

For easier debugging of complex situations (where more than one plugin might have contributed an opinion) I'd like to be able to tell which plugin returned which values.

Is there a way I can do this with Pluggy? If not, could I request it as a feature?

@RonnyPfannschmidt
Copy link
Member

The details are not passed back, however hook tracing should be able to help debug

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

No branches or pull requests

2 participants