source: main/waeup.sirp/trunk/src/waeup/sirp/userscontainer.py @ 9003

Last change on this file since 9003 was 7653, checked in by Henrik Bettermann, 13 years ago

Log user management. If possible use full sentences in log messages. Use the imperative form when process is going to be started and the passive form when the process is finished.

  • Property svn:keywords set to Id
File size: 2.2 KB
RevLine 
[7193]1## $Id: userscontainer.py 7653 2012-02-15 11:03:57Z 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"""
20import grok
[6180]21from zope.event import notify
[4920]22from waeup.sirp.authentication import Account
[7172]23from waeup.sirp.interfaces import IUsersContainer
[7653]24from waeup.sirp.utils.logger import Logger
[4089]25
[7653]26class 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,
[7233]35                description=None, email=None, phone=None, roles=[]):
[4638]36        """Add a new Account instance, created from parameters.
37        """
[4089]38        if title is None:
39            title = name
[7197]40        #if description is None:
41        #    description = title
[7636]42        self[name] = Account(name=name, password=password, title=title,
43                             description=description,
44                             email=email, phone=phone, roles=roles)
[7653]45        self.logger.info('User account %s added.' % name)
[4089]46
47    def addAccount(self, account):
[4638]48        """Add the account passed.
49        """
[4089]50        self[account.name] = account
[7653]51        self.logger.info('User account %s added.' % account.name)
[6180]52
[4089]53    def delUser(self, name):
[4638]54        """Delete user, if an account with the given name exists.
55
56        Do not complain, if the name does not exist.
57        """
[4089]58        if name in self.keys():
59            del self[name]
[7653]60            self.logger.info('User account %s deleted.' % name)
Note: See TracBrowser for help on using the repository browser.