[7193] | 1 | ## $Id: userscontainer.py 7321 2011-12-10 06:15:17Z 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 | ## |
---|
[7321] | 18 | """Users container for the SIRP portal. |
---|
[4089] | 19 | """ |
---|
| 20 | import grok |
---|
[6180] | 21 | from zope.event import notify |
---|
[4920] | 22 | from waeup.sirp.authentication import Account |
---|
[7172] | 23 | from waeup.sirp.interfaces import IUsersContainer |
---|
[4089] | 24 | |
---|
[7172] | 25 | class UsersContainer(grok.Container): |
---|
[4089] | 26 | """A container for principals. |
---|
| 27 | |
---|
| 28 | See interfaces.py and users.txt for extensive description. |
---|
| 29 | """ |
---|
[7172] | 30 | grok.implements(IUsersContainer) |
---|
[4089] | 31 | grok.require('waeup.manageUsers') |
---|
| 32 | |
---|
[7221] | 33 | def addUser(self, name, password, title=None, |
---|
[7233] | 34 | description=None, email=None, phone=None, roles=[]): |
---|
[4638] | 35 | """Add a new Account instance, created from parameters. |
---|
| 36 | """ |
---|
[4089] | 37 | if title is None: |
---|
| 38 | title = name |
---|
[7197] | 39 | #if description is None: |
---|
| 40 | # description = title |
---|
[7233] | 41 | self[name] = Account(name, password, title, description, |
---|
| 42 | email, phone, roles) |
---|
[4089] | 43 | |
---|
| 44 | def addAccount(self, account): |
---|
[4638] | 45 | """Add the account passed. |
---|
| 46 | """ |
---|
[4089] | 47 | self[account.name] = account |
---|
[6180] | 48 | |
---|
[4089] | 49 | def delUser(self, name): |
---|
[4638] | 50 | """Delete user, if an account with the given name exists. |
---|
| 51 | |
---|
| 52 | Do not complain, if the name does not exist. |
---|
| 53 | """ |
---|
[4089] | 54 | if name in self.keys(): |
---|
| 55 | del self[name] |
---|