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

Predicates do not include the tested permission in the context #44

Open
beruic opened this issue Nov 11, 2016 · 4 comments
Open

Predicates do not include the tested permission in the context #44

beruic opened this issue Nov 11, 2016 · 4 comments

Comments

@beruic
Copy link

beruic commented Nov 11, 2016

I'm implementing a custom rule system where a user can have different answers to a permission depending on the obj that is supplied to the predicates. In order to check these permissions fully, I need access to the name of the rule being checked in my predicates.

Is this possible without making obj in my predicates a tuple containing the name as well as the object I want to check on?

@beruic
Copy link
Author

beruic commented Nov 14, 2016

I am working on some small changes which will make predicates support fn(user, obj, perm). There will be a pulle request soon.

@dfunckt
Copy link
Owner

dfunckt commented Nov 28, 2016

This sounds like something useful to have in rules. The clean way to do it is change Predicate.test() to accept the rule as the first argument. This will be a breaking change, so it must come with a major version bump, but I expect impact to be low since probably noone uses this method directly.

@dfunckt dfunckt mentioned this issue May 13, 2017
@jonathanpglick
Copy link

I just ran into an issue like this, too.

I tried to work around it by partially-applying the rule to the predicate function before wrapping it in Predicate but it didn't work because the wrapped function returned by partial() was missing attributes like __name__ and __module__.

@dfunckt
Copy link
Owner

dfunckt commented Jun 20, 2017

Hey @jonathanpglick can you try the context-rule-name branch and see if that works for you? This is WIP, feedback is welcome.

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

No branches or pull requests

3 participants