Ignore:
Timestamp:
21 May 2011, 01:31:03 (13 years ago)
Author:
uli
Message:

Add local roles dicts for user accounts. That seems to
need pretty much machinery, but seems also to work. So,
why not?

We have a new event type, that should be fired when
a local role is set or unset somewhere.

We have also two new event subscribers, one listening
to the new event (and then updates the user account
local roles listings), and another one listening to
IObjectRemoved events.

The latter is the trick to keep the local role listings
in user accounts more or less up-to-date. Without it
these lists would grow and grow, not noticing that
the objects they refer to, have gone already.

We now must think about subscribing to other events.
What happens, when an object is moved or copied.
Will the local roles then be copied as well? And would
that fact be reflected in user accounts?

Beside this we have to find all places in sources
where local roles are set/unset and trigger the new
LocalRoleSetEvent? defined in users.py.

Samples for the whole new stuff are in authentication.txt.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/authentication.py

    r6156 r6180  
    5959    grok.implements(IUserAccount)
    6060
     61    _local_roles = dict()
     62
    6163    def __init__(self, name, password, title=None, description=None,
    6264                 roles = []):
     
    7072        self.setPassword(password)
    7173        self.setRoles(roles)
     74        # We don't want to share this dict with other accounts
     75        self._local_roles = dict()
    7276
    7377    def setPassword(self, password):
     
    98102
    99103    roles = property(getRoles, setRoles)
     104
     105    def getLocalRoles(self):
     106        return self._local_roles
     107
     108    def notifyLocalRoleChanged(self, obj, role_id, granted=True):
     109        objects = self._local_roles.get(role_id, [])
     110        if granted and obj not in objects:
     111            objects.append(obj)
     112        if not granted and obj in objects:
     113            objects.remove(obj)
     114        self._local_roles[role_id] = objects
     115        if len(objects) == 0:
     116            del self._local_roles[role_id]
     117        return
    100118
    101119    def _getPrincipalRoleManager(self):
Note: See TracChangeset for help on using the changeset viewer.