1
0
Fork 0

Code style changes

* make code PEP8 clean (addresses #18)
 * add copyright information to all python files


git-svn-id: file:///home/www/usr01/svn/gnuviechadmin/trunk@257 a67ec6bc-e5d5-0310-a910-815c51eb3124
This commit is contained in:
Jan Dittberner 2008-06-06 19:20:18 +00:00
parent 7c4d25da43
commit 09180938f1
45 changed files with 759 additions and 514 deletions

View file

@ -1,4 +1,3 @@
# -*- python -*-
# -*- coding: utf-8 -*-
#
# Copyright (C) 2008 by Jan Dittberner.
@ -19,12 +18,12 @@
# USA.
#
# Version: $Id$
"""This file defines a facade for exporting gnuviechadmin
functionality via XMLRPC."""
from gnuviechadmin.xmlrpc.users import GVAUsers
class XMLRPCFacade(GVAUsers):
"""This class provides access to selected gnuviechadmin
functionality for use via XMLRPC."""

View file

@ -1,4 +1,3 @@
# -*- python -*-
# -*- coding: utf-8 -*-
#
# Copyright (C) 2008 by Jan Dittberner.
@ -19,7 +18,6 @@
# USA.
#
# Version: $Id$
"""This is the gnuviechadmin.xmlrpc package.
This package provides modules for the XMLRPC interface of the

View file

@ -1,20 +1,47 @@
# -*- python -*-
# -*- coding: utf-8 -*-
#
# Copyright (C) 2007, 2008 by Jan Dittberner.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
#
# Version: $Id$
"""This file provides a authkit.users.Users implementation and several
UserProviders for authenticating different user types and enabling
password change functions."""
from authkit.users import Users, AuthKitNoSuchUserError
import logging
log = logging.getLogger(__name__)
class UserProvider(Users):
"""A base class for user providers."""
def _get_user(self, username, password, role):
return {
'username' : username,
'group' : None,
'password' : password,
'roles' : [role]
}
'username': username,
'group': None,
'password': password,
'roles': [role]}
class ClientUserProvider(UserProvider):
"""A UserProvider implementation class for clients."""
def user(self, username):
print 'checking %s' % username
if username == 'dummy':
@ -24,23 +51,34 @@ class ClientUserProvider(UserProvider):
def list_roles(self):
return ['client']
class MailuserUserProvider(UserProvider):
"""A UserProvider implementation class for mail users."""
def user(self, username):
raise AuthKitNoSuchUserError()
def list_roles(self):
return ['mailuser']
class SysuserUserProvider(UserProvider):
"""A UserProvider implementation class for system users."""
def user(self, username):
raise AuthKitNoSuchUserError()
def list_roles(self):
return ['sysuser']
class GVAUsers(Users):
"""This class provides an implementation of authkit.users.Users
which dispatches several methods to configured UserProvider
implementations."""
def __init__(self, data, userproviders = [], encrypt = None):
"""Initialize the GVAXMLRPCUsers instance."""
"""Initialize the GVAUsers instance."""
Users.__init__(self, data, encrypt)
self.userproviders = [prov(self.data) for prov in userproviders]
@ -65,16 +103,16 @@ class GVAUsers(Users):
def user(self, username):
"""Returns a dictionary in the following format:
.. code-block :: Python
{
'username': username,
'group': group,
'password': password,
'roles': [role1,role2,role3... etc]
}
The role names are ordered alphabetically
Raises an exception if the user doesn't exist."""
for prov in self.userproviders: