File: permissions.py

package info (click to toggle)
zope-pas 1.4-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,084 kB
  • ctags: 1,205
  • sloc: python: 9,373; xml: 348; makefile: 31; sh: 2
file content (59 lines) | stat: -rw-r--r-- 2,095 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights
# Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL).  A copy of the ZPL should accompany this
# distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
""" Product-specifict permissions.

$Id: permissions.py 39144 2004-08-12 15:15:55Z jens $
"""
from AccessControl import ModuleSecurityInfo
from AccessControl import Permissions
from AccessControl.Permission import _registeredPermissions
from AccessControl.Permission import pname
from Globals import ApplicationDefaultPermissions
import Products

security = ModuleSecurityInfo( 'Products.PluggableAuthService.permissions' )

security.declarePublic( 'ManageUsers' )
ManageUsers = Permissions.manage_users

security.declarePublic( 'ManageGroups' )
ManageGroups = "Manage Groups"

security.declarePrivate( 'setDefaultRoles' )
def setDefaultRoles( permission, roles ):

    """ Set the defaults roles for a permission.

    o XXX This ought to be in AccessControl.SecurityInfo.
    """
    registered = _registeredPermissions

    if not registered.has_key( permission ):

        registered[ permission ] = 1
        Products.__ac_permissions__=( Products.__ac_permissions__
                                    + ( ( permission, (), roles ), )
                                    )

        mangled = pname(permission)
        setattr(ApplicationDefaultPermissions, mangled, roles)

security.declarePublic( 'SearchPrincipals' )
SearchPrincipals = 'Search for principals'
setDefaultRoles( SearchPrincipals, ( 'Manager', ) )

security.declarePublic( 'SetOwnPassword' )
SetOwnPassword = 'Set own password'
setDefaultRoles( SetOwnPassword, ( 'Authenticated', ) )