~ubuntu-branches/ubuntu/utopic/python-apptools/utopic

« back to all changes in this revision

Viewing changes to apptools/permissions/default/i_policy_storage.py

  • Committer: Bazaar Package Importer
  • Author(s): Varun Hiremath
  • Date: 2011-07-08 23:55:50 UTC
  • mfrom: (2.1.9 sid)
  • Revision ID: james.westby@ubuntu.com-20110708235550-yz5u79ubeo4dhyfx
Tags: 4.0.0-1
* New upstream release
* Update debian/watch file

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#------------------------------------------------------------------------------
 
2
# Copyright (c) 2008, Riverbank Computing Limited
 
3
# All rights reserved.
 
4
#
 
5
# This software is provided without warranty under the terms of the BSD
 
6
# license included in enthought/LICENSE.txt and may be redistributed only
 
7
# under the conditions described in the aforementioned license.  The license
 
8
# is also available online at http://www.enthought.com/licenses/BSD.txt
 
9
# Thanks for using Enthought open source!
 
10
#
 
11
# Author: Riverbank Computing Limited
 
12
# Description: <Enthought permissions package component>
 
13
#------------------------------------------------------------------------------
 
14
 
 
15
 
 
16
# Enthought library imports.
 
17
from traits.api import Interface
 
18
 
 
19
 
 
20
class PolicyStorageError(Exception):
 
21
    """This is the exception raised by an IPolicyStorage object when an error
 
22
    occurs accessing the database.  Its string representation is displayed as
 
23
    an error message to the user."""
 
24
 
 
25
 
 
26
class IPolicyStorage(Interface):
 
27
    """This defines the interface expected by a PolicyManager to handle the low
 
28
    level storage of the policy data."""
 
29
 
 
30
    ###########################################################################
 
31
    # 'IPolicyStorage' interface.
 
32
    ###########################################################################
 
33
 
 
34
    def add_role(self, name, description, perm_ids):
 
35
        """Add a new role."""
 
36
 
 
37
    def all_roles(self):
 
38
        """Return a list of all roles where each element is a tuple of the name
 
39
        and description."""
 
40
 
 
41
    def delete_role(self, name):
 
42
        """Delete the role with the given name (which will not be empty)."""
 
43
 
 
44
    def get_assignment(self, user_name):
 
45
        """Return a tuple of the user name and list of role names of the
 
46
        assignment for the given user name.  The tuple will contain an empty
 
47
        string and list if the user isn't known."""
 
48
 
 
49
    def get_policy(self, user_name):
 
50
        """Return a tuple of the user name and list of permission names for the
 
51
        user with the given name.  The tuple will contain an empty string and
 
52
        list if the user isn't known."""
 
53
 
 
54
    def is_empty(self):
 
55
        """Return True if the user database is empty.  It will only ever be
 
56
        called once."""
 
57
 
 
58
    def matching_roles(self, name):
 
59
        """Return a list of tuples of the full name, description and list of
 
60
        permission names, sorted by the full name, of all roles that match the
 
61
        given name.  How the name is interpreted (eg. as a regular expression)
 
62
        is determined by the storage."""
 
63
 
 
64
    def modify_role(self, name, description, perm_ids):
 
65
        """Update the description and permissions for the role with the given
 
66
        name (which will not be empty)."""
 
67
 
 
68
    def set_assignment(self, user_name, role_names):
 
69
        """Save the assignment of the given role names to the given user.  Note
 
70
        that there may or may not be an existing assignment for the user."""