Skip to content

Commit

Permalink
Invalidated _users_groups_value volatile after a call of `GroupAwareR…
Browse files Browse the repository at this point in the history
…oleManager.assignRolesToPrincipal` and `GroupAwareRoleManager.assignRoleToPrincipal`
  • Loading branch information
sgeulette committed Sep 1, 2022
1 parent f7ab7af commit c7a19e9
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGES.rst
Expand Up @@ -4,6 +4,9 @@ Changelog
0.63 (unreleased)
-----------------

- Invalidated '_users_groups_value' volatile after a call of `GroupAwareRoleManager.assignRolesToPrincipal` and
`GroupAwareRoleManager.assignRoleToPrincipal`
[sgeulette]
- Removed duplicated classifiers.
[sgeulette]

Expand Down
14 changes: 14 additions & 0 deletions src/imio/helpers/configure.zcml
Expand Up @@ -61,6 +61,20 @@
replacement=".patches.ssl_makeMailer"
preserveOriginal="true" />

<monkey:patch
description="Invalidate '_users_groups_value' volatile after new role set"
class="Products.PlonePAS.plugins.role.GroupAwareRoleManager"
original="assignRolesToPrincipal"
replacement=".patches.assignRolesToPrincipal"
preserveOriginal="true" />

<monkey:patch
description="Invalidate '_users_groups_value' volatile after new role set"
class="Products.PlonePAS.plugins.role.GroupAwareRoleManager"
original="assignRoleToPrincipal"
replacement=".patches.assignRoleToPrincipal"
preserveOriginal="true" />

<utility component=".vocabularies.SortedUsersFactory"
name="imio.helpers.SortedUsers" />

Expand Down
15 changes: 14 additions & 1 deletion src/imio/helpers/patches.py
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-

from imio.helpers.cache import invalidate_cachekey_volatile_for
from Products.PlonePAS.plugins.role import GroupAwareRoleManager
from smtplib import SMTP_SSL
from zope.sendmail.mailer import SMTPMailer

Expand Down Expand Up @@ -29,3 +30,15 @@ def ssl_makeMailer(self):
if self.smtp_port in (465, '465'):
mailer.smtp = SMTP_SSL
return mailer


def assignRolesToPrincipal(self, roles, principal_id, REQUEST=None): # noqa
GroupAwareRoleManager._old_assignRolesToPrincipal(self, roles, principal_id, REQUEST)
# we need to invalidate cachekey
invalidate_cachekey_volatile_for('_users_groups_value')


def assignRoleToPrincipal(self, role_id, principal_id, REQUEST=None):
GroupAwareRoleManager._old_assignRoleToPrincipal(self, role_id, principal_id, REQUEST)
# we need to invalidate cachekey
invalidate_cachekey_volatile_for('_users_groups_value')

0 comments on commit c7a19e9

Please sign in to comment.