Package trac :: Module perm :: Class PermissionSystem

Class PermissionSystem

source code

    object --+    
             |    
core.Component --+
                 |
                PermissionSystem

Permission management sub-system.
Nested Classes

Inherited from core.Component: __metaclass__

Instance Methods
 
__init__(self)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
grant_permission(self, username, action)
Grant the user with the given name permission to perform to specified action.
source code
 
revoke_permission(self, username, action)
Revokes the permission of the specified user to perform an action.
source code
 
get_actions_dict(self, skip=None)
Get all actions from permission requestors as a dict.
source code
 
get_actions(self, skip=None)
Get a list of all actions defined by permission requestors.
source code
 
get_groups_dict(self)
Get all groups as a dict.
source code
 
get_users_dict(self)
Get all users as a dict.
source code
 
get_user_permissions(self, username=None, undefined=False, expand_meta=True)
Return the permissions of the specified user.
source code
 
get_permission_groups(self, username)
Return a sorted list of groups that username belongs to.
source code
 
get_all_permissions(self)
Return all permissions for all users.
source code
 
get_users_with_permission(self, permission)
Return all users that have the specified permission.
source code
 
expand_actions(self, actions)
Helper method for expanding all meta actions.
source code
 
check_permission(self, action, username=None, resource=None, perm=None)
Return True if permission to perform action for the given resource is allowed.
source code
 
get_permission_actions(self)
Implement the global TRAC_ADMIN meta permission.
source code

Inherited from core.Component: __repr__

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __str__, __subclasshook__

Static Methods

Inherited from core.Component: implements

Class Variables
  required = True
  store = <ExtensionOption [trac] 'permission_store'>
  policies = <OrderedExtensionsOption [trac] 'permission_policies'>
  CACHE_EXPIRY = 5
  CACHE_REAP_TIME = 60
  actions = <trac.util.lazy object at 0x7f7ce283cb90>
Properties
  requestors
List of components that implement ~trac.perm.IPermissionRequestor
  group_providers
List of components that implement ~trac.perm.IPermissionGroupProvider

Inherited from object: __class__

Method Details

__init__(self)
(Constructor)

source code 
x.__init__(...) initializes x; see help(type(x)) for signature
Overrides: object.__init__
(inherited documentation)

grant_permission(self, username, action)

source code 
Grant the user with the given name permission to perform to specified action.
Raises:
  • PermissionExistsError - if user already has the permission or is a member of the group.

get_actions_dict(self, skip=None)

source code 

Get all actions from permission requestors as a dict.

The keys are the action names. The values are the additional actions granted by each action. For simple actions, this is an empty list. For meta actions, this is the list of actions covered by the action.

get_groups_dict(self)

source code 

Get all groups as a dict.

The keys are the group names. The values are the group members.

Since: 1.1.3

get_users_dict(self)

source code 

Get all users as a dict.

The keys are the user names. The values are the actions possessed by the user.

Since: 1.1.3

get_user_permissions(self, username=None, undefined=False, expand_meta=True)

source code 

Return the permissions of the specified user.

The return value is a dictionary containing all the actions granted to the user mapped to True.

Parameters:
  • undefined - if True, include actions that are not defined in any of the IPermissionRequestor implementations.
  • expand_meta - if True, expand meta permissions.

get_permission_groups(self, username)

source code 

Return a sorted list of groups that username belongs to.

Groups are recursively expanded such that if username is a member of group1 and group1 is a member of group2, both group1 and group2 will be returned.

Since: 1.3.3

get_all_permissions(self)

source code 

Return all permissions for all users.

The permissions are returned as a list of (subject, action) formatted tuples.

get_users_with_permission(self, permission)

source code 

Return all users that have the specified permission.

Users are returned as a list of user names.


Property Details

requestors

List of components that implement ~trac.perm.IPermissionRequestor
Get Method:
unreachable.extensions(component) - Return a list of components that declare to implement the extension point interface.

group_providers

List of components that implement ~trac.perm.IPermissionGroupProvider
Get Method:
unreachable.extensions(component) - Return a list of components that declare to implement the extension point interface.