stalker.core.models.PermissionGroup — Stalker v0.1.1.a9 documentation

### Navigation

- index
- next |
- previous |
- Stalker v0.1.1.a9 documentation »

# stalker.core.models.PermissionGroup

class `stalker.core.models.` `PermissionGroup`(**kwargs)

  Bases: `stalker.core.models.SimpleEntity`

  Manages permission in the system.

  A PermissionGroup object maps permission for tasks like Create, Read, Update, Delete operations in the system to available classes in the system.

  It reads the `CORE_MODEL_CLASSES` list to get the list of available classes which can be created. It then stores a binary value for each of the class.

  A `User` can be in several `PermissionGroup`s. The combined permission for an object is calculated with an `OR` (`^`) operation. So if one of the `PermissionGroup`s of the `User` is allowing the action then the user is allowed to do the operation.

  The permissions are stored in a dictionary. The key is the class name and the value is a 4-bit binary integer value like 0b0001.

  0b | 0 | 0 | 0 | 0
  binary identifier | Create Bit | Read Bit | Update Bit | Delete Bit

  Parameters: | permissions (dict) – A Python dictionary showing the permissions. The key is the name of the Class and the value is the permission bit.

  NOTE TO DEVELOPERS: a Dictionary-Based Collections should be used in SQLAlchemy.

  `__init__`(**kwargs)

  Methods

  `__init__`(**kwargs) |

  Attributes

  `code` | The code name of this object.
  `created_by` | The `User` who has created this object.
  `date_created` | A `datetime.datetime` instance showing the creation date and time of this object.
  `date_updated` | A `datetime.datetime` instance showing the update date and time of this object.
  `description` | Description of this object.
  `name` | Name of this object
  `nice_name` | Nice name of this object.
  `type` | The type of the object.
  `updated_by` | The `User` who has updated this object.

  `code`

    The code name of this object.

    It accepts string or unicode values and any other kind of objects will be converted to string. In any update to the name attribute the code also will be updated. If the code is not initialized or given as None, it will be set to the uppercase version of the nice_name attribute. Setting the code attribute to None will reset it to the default value. The default value is the upper case form of the nice_name.

  `created_by`

    The `User` who has created this object.

  `date_created`

    A `datetime.datetime` instance showing the creation date and time of this object.

  `date_updated`

    A `datetime.datetime` instance showing the update date and time of this object.

  `description`

    Description of this object.

  `name`

    Name of this object

  `nice_name`

    Nice name of this object.

    It has the same value with the name (contextually) but with a different format like, all the white spaces replaced by underscores (“_”), all the CamelCase form will be expanded by underscore (_) characters and it is always lower case.

    There is also the `code` attribute which is simply the upper case form of `nice_name` if it is not defined differently (i.e set to another value).

  `type`

    The type of the object.

    It is an instance of `Type` with a proper `target_entity_type`.

  `updated_by`

    The `User` who has updated this object.

### Navigation

- index
- next |
- previous |
- Stalker v0.1.1.a9 documentation »