1 | """Users (principal) for the WAeUP portal. |
---|
2 | """ |
---|
3 | import grok |
---|
4 | from waeup.authentication import Account |
---|
5 | from waeup.interfaces import IUserContainer |
---|
6 | from waeup.viewlets import LeftSidebar, MainArea, Index |
---|
7 | |
---|
8 | class UserContainer(grok.Container): |
---|
9 | """A container for principals. |
---|
10 | |
---|
11 | See interfaces.py and users.txt for extensive description. |
---|
12 | """ |
---|
13 | grok.implements(IUserContainer) |
---|
14 | grok.require('waeup.manageUsers') |
---|
15 | |
---|
16 | def addUser(self, name, password, title=None, description=None): |
---|
17 | if title is None: |
---|
18 | title = name |
---|
19 | if description is None: |
---|
20 | description = title |
---|
21 | self[name] = Account(name, password, title, description) |
---|
22 | |
---|
23 | def addAccount(self, account): |
---|
24 | self[account.name] = account |
---|
25 | |
---|
26 | def delUser(self, name): |
---|
27 | if name in self.keys(): |
---|
28 | del self[name] |
---|
29 | |
---|
30 | class UserContainerView(Index): |
---|
31 | grok.require('waeup.manageUsers') |
---|
32 | grok.context(IUserContainer) |
---|
33 | grok.name('index') |
---|
34 | def render(self, *args, **kw): |
---|
35 | return super(UserContainerView, self).render(*args, **kw) |
---|
36 | |
---|
37 | class UserContainerMain(grok.Viewlet): |
---|
38 | grok.require('waeup.manageUsers') |
---|
39 | grok.viewletmanager(MainArea) |
---|
40 | grok.template('usermain') |
---|
41 | |
---|
42 | |
---|