permission package
Subpackages
- permission.decorators package
- permission.logics package
- permission.templatetags package
- permission.tests package
- Subpackages
- permission.tests.test_decorators package
- Submodules
- permission.tests.test_decorators.test_classbase module
- permission.tests.test_decorators.test_functionbase module
- permission.tests.test_decorators.test_methodbase module
- permission.tests.test_decorators.test_permission_required module
- permission.tests.test_decorators.utils module
- Module contents
- permission.tests.test_logics package
- Submodules
- permission.tests.test_logics.test_author module
- permission.tests.test_logics.test_base module
- permission.tests.test_logics.test_collaborators module
- permission.tests.test_logics.test_groupin module
- permission.tests.test_logics.test_oneself module
- permission.tests.test_logics.test_staff module
- Module contents
- permission.tests.test_templatetags package
- permission.tests.test_utils package
- permission.tests.test_decorators package
- Submodules
- permission.tests.compat module
- permission.tests.models module
- permission.tests.test_backends module
- permission.tests.test_handlers module
- permission.tests.utils module
- Module contents
- Subpackages
- permission.utils package
Submodules
permission.backends module
Logical permission backends module
- class permission.backends.PermissionBackend[source]
Bases:
object
A handler based permission backend
- 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 andPERMISSION_CHECK_PERMISSION_PRESENCE
isTrue
insettings
module.- Parameters
user_obj (django user model instance) – A django user model instance which is checked
app_label (string) – app_label.codename formatted permission string
- Returns
Whether the specified user have specified permission.
- Return type
boolean
- Raises
django.core.exceptions.ObjectDoesNotExist – If the specified string permission does not exist and
PERMISSION_CHECK_PERMISSION_PRESENCE
isTrue
insettings
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 andPERMISSION_CHECK_PERMISSION_PRESENCE
isTrue
insettings
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
Whether the specified user have specified permission (of specified object).
- Return type
boolean
- Raises
django.core.exceptions.ObjectDoesNotExist – If the specified string permission does not exist and
PERMISSION_CHECK_PERMISSION_PRESENCE
isTrue
insettings
module.
- supports_anonymous_user = True
- supports_inactive_user = True
- supports_object_permissions = True
permission.compat module
permission.conf module
django-permission2 application configure
permission.handlers module
- class permission.handlers.LogicalPermissionHandler(model)[source]
Bases:
PermissionHandler
Permission handler class which use permission logics to determine the permission
- 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
Whether the specified user have specified permission (of specified object).
- Return type
boolean
- class permission.handlers.PermissionHandler(model_or_app_label)[source]
Bases:
object
Abstract permission handler class
- property excludes
- get_supported_app_labels()[source]
Get app labels which this handler can treat. Specified with
includes
andexcludes
of this instance.- Returns
A set instance of app_label
- Return type
set
- get_supported_permissions()[source]
Get permissions which this handler can treat. Specified with
includes
andexcludes
of this instance.- Returns
A set instance of app_label.codename formatted permission strings
- Return type
set
- 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
Whether the specified user have any permissions of specified app
- Return type
boolean
- 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 – Whether the specified user have specified permission (of specified object).
.. note:: – Sub class must override this method.
- property includes