Package expedient :: Package common :: Package permissions :: Module managers :: Class ObjectPermissionManager
[hide private]
[frames] | no frames]

Class ObjectPermissionManager

source code


Adds some useful methods to the default manager type.

Instance Methods [hide private]
 
__init__(self)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
(ExpedientPermission, Model)
get_perm_and_obj(self, permission, obj_or_class)
Turn permission into a ExpedientPermission instance if it is not (and it is a permission name).
source code
(ObjectPermission, bool)
get_or_create_for_object_or_class(self, permission, obj_or_class)
Get the object permission permission for object obj.
source code
ObjectPermission
get_for_object_or_class(self, permission, obj_or_class)
Get the object permission with name perm_name for object obj.
source code
 
get_permitted_objects(self, klass, perm_names, permittee)
Get a queryset of klass instances that the object permittee has permissions named by perm_names for.
source code

Inherited from utils.managers.GenericObjectManager: filter_for_class, filter_for_objects, filter_from_instance, filter_from_queryset, get_objects_queryset, get_or_create_from_instance

Inherited from django.db.models.manager.Manager: aggregate, all, annotate, complex_filter, contribute_to_class, count, create, dates, db_manager, defer, distinct, exclude, exists, extra, filter, get, get_empty_query_set, get_or_create, get_query_set, in_bulk, iterator, latest, none, only, order_by, raw, reverse, select_related, update, using, values, values_list

Inherited from django.db.models.manager.Manager (private): _copy_to_model, _insert, _set_creation_counter, _update

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

Class Variables [hide private]

Inherited from utils.managers.GenericObjectManager: use_for_related_fields

Inherited from django.db.models.manager.Manager: creation_counter

Properties [hide private]

Inherited from django.db.models.manager.Manager: db

Inherited from object: __class__

Method Details [hide private]

__init__(self)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Parameters:
  • ct_field - name of the ForeignKey field pointing to ContentType. Default is "content_type".
  • fk_field - name of the ID field for objects. Default is object_id.
Overrides: object.__init__
(inherited documentation)

get_perm_and_obj(self, permission, obj_or_class)

source code 

Turn permission into a ExpedientPermission instance if it is not (and it is a permission name). Also turn obj_or_class into a model instance if it is a class.

Parameters:
  • permission (ExpedientPermission or string) - the permission's name or the ExpedientPermission instance
  • obj_or_class (a model instance or class.) - If this is a class, it will be returned as a ContentType instance
Returns: (ExpedientPermission, Model)
Tuple (permission as ExpedientPermission, obj_or_class as a Model instance).

get_or_create_for_object_or_class(self, permission, obj_or_class)

source code 

Get the object permission permission for object obj.

Parameters:
Returns: (ObjectPermission, bool)
tuple (object permission we are looking for, created)

get_for_object_or_class(self, permission, obj_or_class)

source code 

Get the object permission with name perm_name for object obj.

Parameters:
Returns: ObjectPermission
the object permission we're looking for

get_permitted_objects(self, klass, perm_names, permittee)

source code 

Get a queryset of klass instances that the object permittee has permissions named by perm_names for.

Parameters:
  • klass (class) - the class of the objects we want.
  • perm_names ([str]) - list of permission names.
  • permittee (Model instance not necessarily a Permittee) - permission exerciser for whom we're looking object permissions.