You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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).
The text was updated successfully, but these errors were encountered:
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).
The text was updated successfully, but these errors were encountered: