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

Cannot batch different combinations of multiple permissions, multiple users, and multiple objects #779

Open
JCourt1 opened this issue Jun 16, 2022 · 0 comments

Comments

@JCourt1
Copy link

JCourt1 commented Jun 16, 2022

Currently, the methods in the BaseObjectPermissionManager do not allow assigning multiple permissions for multiple users and for multiple objects. Likewise, the assign_perm function in shortcuts does not even allow assigning multiple permissions at once. The problem with this is that permission assignments are very slow, because they cannot be properly batched together.

I actually went ahead and did a PR for this, but forgot to create the issue. Here it is:

#777

This PR adds in methods to the object permission manager, and also adds two new shortcuts: bulk_assign_perms and bulk_remove_perms. In addition, I have also added a commit parameter, which allows the user of the shortcuts to go even further with the batching, and accumulate permissions so that they can all be persisted in one fell swoop. I have ensured that previous behaviour is left intact, and the new behaviour is well tested.

Having applied these changes in a work project which relies heavily on django guardian, I have seen a big decrease in the time taken for the entire test suite to complete (down to ~20 seconds from 3 minutes).

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

1 participant