Rev | Line | |
---|
[7172] | 1 | """Users container for the WAeUP portal. |
---|
[4089] | 2 | """ |
---|
| 3 | import grok |
---|
[6180] | 4 | from zope.event import notify |
---|
[4920] | 5 | from waeup.sirp.authentication import Account |
---|
[7172] | 6 | from waeup.sirp.interfaces import IUsersContainer |
---|
[4089] | 7 | |
---|
[7172] | 8 | class UsersContainer(grok.Container): |
---|
[4089] | 9 | """A container for principals. |
---|
| 10 | |
---|
| 11 | See interfaces.py and users.txt for extensive description. |
---|
| 12 | """ |
---|
[7172] | 13 | grok.implements(IUsersContainer) |
---|
[4089] | 14 | grok.require('waeup.manageUsers') |
---|
| 15 | |
---|
[4634] | 16 | def addUser(self, name, password, title=None, description=None, roles=[]): |
---|
[4638] | 17 | """Add a new Account instance, created from parameters. |
---|
| 18 | """ |
---|
[4089] | 19 | if title is None: |
---|
| 20 | title = name |
---|
| 21 | if description is None: |
---|
| 22 | description = title |
---|
[4634] | 23 | self[name] = Account(name, password, title, description, roles) |
---|
[4089] | 24 | |
---|
| 25 | def addAccount(self, account): |
---|
[4638] | 26 | """Add the account passed. |
---|
| 27 | """ |
---|
[4089] | 28 | self[account.name] = account |
---|
[6180] | 29 | |
---|
[4089] | 30 | def delUser(self, name): |
---|
[4638] | 31 | """Delete user, if an account with the given name exists. |
---|
| 32 | |
---|
| 33 | Do not complain, if the name does not exist. |
---|
| 34 | """ |
---|
[4089] | 35 | if name in self.keys(): |
---|
| 36 | del self[name] |
---|
Note: See
TracBrowser for help on using the repository browser.