[7193] | 1 | ## $Id: userscontainer.py 8757 2012-06-19 07:28:08Z henrik $ |
---|
| 2 | ## |
---|
| 3 | ## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann |
---|
| 4 | ## This program is free software; you can redistribute it and/or modify |
---|
| 5 | ## it under the terms of the GNU General Public License as published by |
---|
| 6 | ## the Free Software Foundation; either version 2 of the License, or |
---|
| 7 | ## (at your option) any later version. |
---|
| 8 | ## |
---|
| 9 | ## This program is distributed in the hope that it will be useful, |
---|
| 10 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 11 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 12 | ## GNU General Public License for more details. |
---|
| 13 | ## |
---|
| 14 | ## You should have received a copy of the GNU General Public License |
---|
| 15 | ## along with this program; if not, write to the Free Software |
---|
| 16 | ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
| 17 | ## |
---|
[7819] | 18 | """Users container for the Kofa portal. |
---|
[4089] | 19 | """ |
---|
| 20 | import grok |
---|
[6180] | 21 | from zope.event import notify |
---|
[7811] | 22 | from waeup.kofa.authentication import Account |
---|
| 23 | from waeup.kofa.interfaces import IUsersContainer |
---|
| 24 | from waeup.kofa.utils.logger import Logger |
---|
[4089] | 25 | |
---|
[7653] | 26 | class UsersContainer(grok.Container, Logger): |
---|
[4089] | 27 | """A container for principals. |
---|
| 28 | |
---|
| 29 | See interfaces.py and users.txt for extensive description. |
---|
| 30 | """ |
---|
[7172] | 31 | grok.implements(IUsersContainer) |
---|
[4089] | 32 | grok.require('waeup.manageUsers') |
---|
| 33 | |
---|
[7221] | 34 | def addUser(self, name, password, title=None, |
---|
[8757] | 35 | description=None, email=None, phone=None, |
---|
| 36 | public_name= None, roles=[]): |
---|
[4638] | 37 | """Add a new Account instance, created from parameters. |
---|
| 38 | """ |
---|
[4089] | 39 | if title is None: |
---|
| 40 | title = name |
---|
[7197] | 41 | #if description is None: |
---|
| 42 | # description = title |
---|
[7636] | 43 | self[name] = Account(name=name, password=password, title=title, |
---|
[8757] | 44 | description=description, public_name=public_name, |
---|
[7636] | 45 | email=email, phone=phone, roles=roles) |
---|
[8739] | 46 | #self.logger.info('User account %s added.' % name) |
---|
[4089] | 47 | |
---|
| 48 | def addAccount(self, account): |
---|
[4638] | 49 | """Add the account passed. |
---|
| 50 | """ |
---|
[4089] | 51 | self[account.name] = account |
---|
[8739] | 52 | #self.logger.info('User account %s added.' % account.name) |
---|
[6180] | 53 | |
---|
[4089] | 54 | def delUser(self, name): |
---|
[4638] | 55 | """Delete user, if an account with the given name exists. |
---|
| 56 | |
---|
| 57 | Do not complain, if the name does not exist. |
---|
| 58 | """ |
---|
[4089] | 59 | if name in self.keys(): |
---|
| 60 | del self[name] |
---|
[8739] | 61 | #self.logger.info('User account %s deleted.' % name) |
---|