def updatePrincipal(self, id, login, title, description, passwd, roles): if not self.writeable: self.msg = (u'Principal could not be updated: ' u'the authenticator holding the principals ' u'seems not to be writeable.') return if id is None: id = login principals = self.getPrincipals() if login not in [x.login for x in principals]: self.msg = (u'Login `%s` does not exist.' % (login, )) return for key in [login, title]: if key is None or key == '': self.msg = (u'Login and title must not be empty.') return # Update generic data... principal = self.userfolder[id[len(self.userfolder.prefix):]] principal.title = title principal.description = description principal.password = passwd and passwd or principal.password # Update roles... role_manager = IPrincipalRoleManager(self.context) role_manager = removeSecurityProxy(role_manager) for role in self.roles: if role in roles: role_manager.assignRoleToPrincipal(role, id) else: role_manager.unsetRoleForPrincipal(role, id) self.msg = u'Principal `%s` successfully updated.' % (title, )