permission package

Subpackages

Submodules

permission.backends module

Logical permission backends module

class permission.backends.PermissionBackend[source]

Bases: object

A handler based permission backend

Methods

authenticate(username, password)[source]

Always return None to prevent authentication within this backend.

has_module_perms(user_obj, app_label)[source]

Check if user have permission of specified app based on registered handlers.

It will raise ObjectDoesNotExist exception when the specified string permission does not exist and PERMISSION_CHECK_PERMISSION_PRESENCE is True in settings module.

Parameters:

user_obj : django user model instance

A django user model instance which be checked

perm : string

app_label.codename formatted permission string

obj : None or django model instance

None or django model instance for object permission

Returns:

boolean

Wheter the specified user have specified permission (of specified object).

Raises:

django.core.exceptions.ObjectDoesNotExist

If the specified string permission does not exist and PERMISSION_CHECK_PERMISSION_PRESENCE is True in settings module.

has_perm(user_obj, perm, obj=None)[source]

Check if user have permission (of object) based on registered handlers.

It will raise ObjectDoesNotExist exception when the specified string permission does not exist and PERMISSION_CHECK_PERMISSION_PRESENCE is True in settings module.

Parameters:

user_obj : django user model instance

A django user model instance which be checked

perm : string

app_label.codename formatted permission string

obj : None or django model instance

None or django model instance for object permission

Returns:

boolean

Wheter the specified user have specified permission (of specified object).

Raises:

django.core.exceptions.ObjectDoesNotExist

If the specified string permission does not exist and PERMISSION_CHECK_PERMISSION_PRESENCE is True in settings module.

supports_anonymous_user = True
supports_inactive_user = True
supports_object_permissions = True

permission.compat module

permission.compat.isiterable(x)[source]

permission.conf module

django-permission application configure

permission.handlers module

class permission.handlers.LogicalPermissionHandler(model)[source]

Bases: permission.handlers.PermissionHandler

Permission handler class which use permission logics to determine the permission

Attributes

Methods

has_perm(user_obj, perm, obj=None)[source]

Check if user have permission (of object) based on specified models’s _permission_logics attribute.

The result will be stored in user_obj as a cache to reduce method call.

Parameters:

user_obj : django user model instance

A django user model instance which be checked

perm : string

app_label.codename formatted permission string

obj : None or django model instance

None or django model instance for object permission

Returns:

boolean

Wheter the specified user have specified permission (of specified object).

class permission.handlers.PermissionHandler(model_or_app_label)[source]

Bases: object

Abstract permission handler class

Attributes

Methods

excludes
get_supported_app_labels()[source]

Get app labels which this handler can treat. Specified with includes and excludes of this instance.

Returns:

set

A set instance of app_label

get_supported_permissions()[source]

Get permissions which this handler can treat. Specified with includes and excludes of this instance.

Returns:

set

A set instance of app_label.codename formatted permission strings

has_module_perms(user_obj, app_label)[source]

Check if user have permission of specified app

Parameters:

user_obj : django user model instance

A django user model instance which be checked

app_label : string

Django application name

Returns:

boolean

Wheter the specified user have any permissions of specified app

has_perm(user_obj, perm, obj=None)[source]

Check if user have permission (of object)

Parameters:

user_obj : django user model instance

A django user model instance which be checked

perm : string

app_label.codename formatted permission string

obj : None or django model instance

None or django model instance for object permission

Returns:

boolean

Wheter the specified user have specified permission (of specified object).

Note

Sub class must override this method.

includes

permission.models module

Module contents

django-permission