source: waeup/branches/ulif-rewrite/src/waeup/users.py @ 4095

Last change on this file since 4095 was 4095, checked in by uli, 16 years ago

Add first view/viewlet for user container.

File size: 1.2 KB
Line 
1"""Users (principal) for the WAeUP portal.
2"""
3import grok
4from waeup.authentication import Account
5from waeup.interfaces import IUserContainer
6from waeup.viewlets import LeftSidebar, MainArea, Index
7
8class 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
30class 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   
37class UserContainerMain(grok.Viewlet):
38    grok.require('waeup.manageUsers')
39    grok.viewletmanager(MainArea)
40    grok.template('usermain')
41
42
Note: See TracBrowser for help on using the repository browser.