## $Id: userscontainer.py 7819 2012-03-08 22:28:46Z henrik $ ## ## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 2 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; if not, write to the Free Software ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ## """Users container for the Kofa portal. """ import grok from zope.event import notify from waeup.kofa.authentication import Account from waeup.kofa.interfaces import IUsersContainer from waeup.kofa.utils.logger import Logger class UsersContainer(grok.Container, Logger): """A container for principals. See interfaces.py and users.txt for extensive description. """ grok.implements(IUsersContainer) grok.require('waeup.manageUsers') def addUser(self, name, password, title=None, description=None, email=None, phone=None, roles=[]): """Add a new Account instance, created from parameters. """ if title is None: title = name #if description is None: # description = title self[name] = Account(name=name, password=password, title=title, description=description, email=email, phone=phone, roles=roles) self.logger.info('User account %s added.' % name) def addAccount(self, account): """Add the account passed. """ self[account.name] = account self.logger.info('User account %s added.' % account.name) def delUser(self, name): """Delete user, if an account with the given name exists. Do not complain, if the name does not exist. """ if name in self.keys(): del self[name] self.logger.info('User account %s deleted.' % name)