def _set_group(self, new_group, current_groups): """ Helper method to change ownership from a possible collection of groups to a single other group. """ already_member = False for gname in current_groups: if gname == new_group: already_member = True continue grp = srusers.group(gname) if self.username in grp.members: grp.user_rm(self.username) self._modified_groups.add(grp) if not already_member: new_grp = srusers.group(new_group) new_grp.user_add(self.username) self._modified_groups.add(new_grp)
def delete(self): for gid in self._user.groups(): g = srusers.group(gid) g.user_rm(self.username) g.save() self._user.delete()
def __init__(self, group_name): self._group = srusers.group(group_name) self.group_name = group_name
def _group(self): if self._cached_group is None: self._cached_group = srusers.group(self._group_name) return self._cached_group
def __init__(self, name): self._group = srusers.group(name) self.name = name