Back to index

plone3  3.1.7
permissions.py
Go to the documentation of this file.
00001 ##############################################################################
00002 #
00003 # Copyright (c) 2001 Zope Corporation and Contributors. All Rights
00004 # Reserved.
00005 #
00006 # This software is subject to the provisions of the Zope Public License,
00007 # Version 2.1 (ZPL).  A copy of the ZPL should accompany this
00008 # distribution.
00009 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
00010 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00011 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
00012 # FOR A PARTICULAR PURPOSE.
00013 #
00014 ##############################################################################
00015 """ Product-specifict permissions.
00016 
00017 $Id: permissions.py 39144 2004-08-12 15:15:55Z jens $
00018 """
00019 from AccessControl import ModuleSecurityInfo
00020 from AccessControl import Permissions
00021 from AccessControl.Permission import _registeredPermissions
00022 from AccessControl.Permission import pname
00023 from Globals import ApplicationDefaultPermissions
00024 import Products
00025 
00026 security = ModuleSecurityInfo( 'Products.PluggableAuthService.permissions' )
00027 
00028 security.declarePublic( 'ManageUsers' )
00029 ManageUsers = Permissions.manage_users
00030 
00031 security.declarePublic( 'ManageGroups' )
00032 ManageGroups = "Manage Groups"
00033 
00034 security.declarePrivate( 'setDefaultRoles' )
00035 def setDefaultRoles( permission, roles ):
00036 
00037     """ Set the defaults roles for a permission.
00038 
00039     o XXX This ought to be in AccessControl.SecurityInfo.
00040     """
00041     registered = _registeredPermissions
00042 
00043     if not registered.has_key( permission ):
00044 
00045         registered[ permission ] = 1
00046         Products.__ac_permissions__=( Products.__ac_permissions__
00047                                     + ( ( permission, (), roles ), )
00048                                     )
00049 
00050         mangled = pname(permission)
00051         setattr(ApplicationDefaultPermissions, mangled, roles)
00052 
00053 security.declarePublic( 'SearchPrincipals' )
00054 SearchPrincipals = 'Search for principals'
00055 setDefaultRoles( SearchPrincipals, ( 'Manager', ) )
00056 
00057 security.declarePublic( 'SetOwnPassword' )
00058 SetOwnPassword = 'Set own password'
00059 setDefaultRoles( SetOwnPassword, ( 'Authenticated', ) )