grate.access

class grate.access.Entity

An Entity is an object that can have accesses.

class grate.access.EntityCollection

An EntityCollection is an object that contains Entitys.

owner

The reference to the owner.

entities

The list of Entitys contained in this collection.

get_numeric_access(entity)
Parameters:entity – An Entity.
Returns:A number.
has_admin_access(entity)
Parameters:entity – An Entity.
Returns:True if the given entity is an administrator of this collection.
add_access(entity, access)
Parameters:
  • entity – An Entity.
  • access – The access level as a string. See VALID_ACCESS_MAP.
Returns:

The access object.

Return type:

EntityAccess

remove_access(entity)

Removes access from the given entity. :param entity: An Entity.

classmethod reverse_access_map()
Returns:The mapping from the access level (number) to its name (string).
classmethod levels()
Returns:The list of access level names.
classmethod get_access_name(level)
Parameters:level – A number.
Returns:The name of the given access level.
Raises :KeyError when the level is not found.
classmethod get_access_value(level_name)
Parameters:level_name – The name of the access level.
Returns:The numeric access level.
Raises :KeyError when the level_name is not found.
classmethod is_valid_access(access)
Parameters:access – The access level name.
Returns:True if the level name is valid.
class grate.access.EntityAccess
ns

The namespace of the access domain.

entity

The Entity holding the access.

provider

The object granting access to the entity.

access

The numerical access level > 1.

classmethod get_access(ns, entity, provider)
Parameters:
  • ns (string) – The namespace of the access domain.
  • entity (Entity) – The entity.
  • provider (mongoengine.Document) – The provider of the access.
Returns:

The access level of the given entity to the given provider.

Return type:

int

classmethod get_providers(ns, entity)
Parameters:
  • ns (string) – The namespace of the access domain.
  • entity (Entity) – An entity.
Returns:

A generator returning all providers for the given entity in the namespace.

classmethod create(ns, entity, provider, access)
Parameters:
  • ns (string) – The namespace of the access domain.
  • entity (Entity) – An entity.
  • provider (mongoengine.Document) – The provider of the access.
Returns:

An access object.

Return type:

EntityAccess

Previous topic

grate.githandle

Next topic

grate.atomic

This Page