django_prbac Package

django_prbac Package

admin Module

arbitrary Module

django_prbac.arbitrary.role(name=None, friendly_name=None, save=True, **kwargs)
django_prbac.arbitrary.grant(from_role=None, to_role=None, save=True, **kwargs)
django_prbac.arbitrary.unique_name(prefix=None, suffix=None)

decorators Module

django_prbac.decorators.requires_privilege(role_name, **assignment)[source]

exceptions Module

exception django_prbac.exceptions.PermissionDenied[source]

Bases: exceptions.Exception

fields Module

class django_prbac.fields.StringListField(verbose_name=None, name=None, primary_key=False, max_length=None, unique=False, blank=False, null=False, db_index=False, rel=None, default=<class django.db.models.fields.NOT_PROVIDED at 0x3fd0188>, editable=True, serialize=True, unique_for_date=None, unique_for_month=None, unique_for_year=None, choices=None, help_text=u'', db_column=None, db_tablespace=None, auto_created=False, validators=[], error_messages=None)[source]

Bases: django.db.models.fields.subclassing.NewBase

A Django field for lists of strings

contribute_to_class(cls, name)
get_prep_value(value)[source]
is_string_list(value)[source]
to_python(value)[source]

Handles exactly two cases.

  1. The value is already a (unicode, not bytes) string list. - then it is returned as-is
  2. The value is a string (not super sure how Django deals w/ database fields w.r.t. unicode) - then it is deserialized and return if and only if it is a string list
value_to_string(obj)[source]
class django_prbac.fields.StringSetField(verbose_name=None, name=None, primary_key=False, max_length=None, unique=False, blank=False, null=False, db_index=False, rel=None, default=<class django.db.models.fields.NOT_PROVIDED at 0x3fd0188>, editable=True, serialize=True, unique_for_date=None, unique_for_month=None, unique_for_year=None, choices=None, help_text=u'', db_column=None, db_tablespace=None, auto_created=False, validators=[], error_messages=None)[source]

Bases: django.db.models.fields.subclassing.NewBase

A Django field for set of strings.

contribute_to_class(cls, name)
get_prep_value(value)[source]
is_string_set(value)[source]
to_python(value)[source]

Handles exactly two cases.

  1. The value is already a (unicode, not bytes) string set. - then it is returned as-is
  2. The value is a string (not super sure how Django deals w/ database fields w.r.t. unicode) - then it is deserialized and returned as a set if and only if it is a string list

mock_settings Module

Settings just for running the django-prbac tests or checking out the admin site.

models Module

class django_prbac.models.Role(*args, **kwargs)[source]

Bases: django.db.models.base.Model

A PRBAC role, aka a Role parameterized by a set of named variables. Roles also model privileges: They differ only in that privileges only refer to real-world consequences when all parameters are instantiated.

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception Role.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

Role.assignment[source]

A Role stored in the database always has an empty assignment.

Role.has_privilege(privilege)[source]

Shortcut for checking privileges easily for roles with no params (aka probably users)

Role.instantiate(assignment)[source]

An instantiation of this role with some parameters fixed via the provided assignments.

Role.members
Role.memberships_granted
Role.objects = <django.db.models.manager.Manager object at 0x42b7d10>
class django_prbac.models.Grant(*args, **kwargs)[source]

Bases: django.db.models.base.Model

A parameterized membership between a sub-role and super-role. The parameters applied to the super-role are all those.

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception Grant.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

Grant.from_role
Grant.get_assignment_json(model_instance)
Grant.instantiated_to_role(assignment)[source]

Returns the super-role instantiated with the parameters of the membership composed with the parameters passed in.

Grant.objects = <django.db.models.manager.Manager object at 0x42c1390>
Grant.set_assignment_json(model_instance, value)
Grant.to_role
class django_prbac.models.RoleInstance(role, assignment)[source]

Bases: object

A parameterized role along with some parameters that are fixed. Note that this is not a model but only a transient Python object.

has_privilege(privilege)[source]

True if this instantiated role is allowed the privilege passed in, (which is itself an RoleInstance)

instantiate(assignment)[source]

This role further instantiated with the additional assignment. Note that any parameters that are already fixed are not actually available for being assigned, so will _not_ change.

urls Module