[gen] Bugfix in the 'change user id' function. Now, the method browses every object in the database and updates local roles where the old ID was potentially mentioned.

This commit is contained in:
Gaetan Delannay 2012-07-11 17:27:40 +02:00
parent 7e31304c30
commit a0837a758f
2 changed files with 41 additions and 8 deletions

View file

@ -939,6 +939,19 @@ class BaseMixin:
self.reindex()
return updated
def applyUserIdChange(self, oldId, newId):
'''A user whose ID was p_oldId has now p_newId. If the old ID was
mentioned in self's local roles, update it to the new ID. This
method returns 1 if a change occurred, 0 else.'''
if oldId in self.__ac_local_roles__:
localRoles = self.__ac_local_roles__.copy()
localRoles[newId] = localRoles[oldId]
del localRoles[oldId]
self.__ac_local_roles__ = localRoles
self.reindex()
return 1
return 0
def hasHistory(self):
'''Has this object an history?'''
if hasattr(self.aq_base, 'workflow_history') and self.workflow_history: