Back to index

plone3  3.1.7
Functions | Variables
DCWorkflow.utils Namespace Reference

Functions

def ac_inherited_permissions
def modifyRolesForPermission
def modifyRolesForGroup

Variables

tuple security = ModuleSecurityInfo('Products.DCWorkflow.utils')
tuple _dtmldir = os.path.join( package_home( globals() ), 'dtml' )
tuple _xmldir = os.path.join( package_home( globals() ), 'xml' )
tuple Message = _MessageFactory('cmf_default')

Function Documentation

def DCWorkflow.utils.ac_inherited_permissions (   ob,
  all = 0 
)

Definition at line 32 of file utils.py.

00032 
00033 def ac_inherited_permissions(ob, all=0):
00034     # Get all permissions not defined in ourself that are inherited
00035     # This will be a sequence of tuples with a name as the first item and
00036     # an empty tuple as the second.
00037     d = {}
00038     perms = getattr(ob, '__ac_permissions__', ())
00039     for p in perms: d[p[0]] = None
00040     r = gather_permissions(ob.__class__, [], d)
00041     if all:
00042        if hasattr(ob, '_subobject_permissions'):
00043            for p in ob._subobject_permissions():
00044                pname=p[0]
00045                if not d.has_key(pname):
00046                    d[pname]=1
00047                    r.append(p)
00048        r = list(perms) + r
00049     return r

Here is the caller graph for this function:

def DCWorkflow.utils.modifyRolesForGroup (   ob,
  group,
  grant_roles,
  managed_roles 
)
Modifies local roles for one group.

Definition at line 68 of file utils.py.

00068 
00069 def modifyRolesForGroup(ob, group, grant_roles, managed_roles):
00070     """Modifies local roles for one group.
00071     """
00072     local_roles = getattr(ob, '__ac_local_roles__', None)
00073     if local_roles is None:
00074         local_roles = {}
00075     roles = local_roles.get(group)
00076     if not roles:
00077         if not grant_roles:
00078             # No roles exist and no grants requested.  Leave unchanged.
00079             return 0
00080         else:
00081             # Add new roles for this group.
00082             local_roles[group] = list(grant_roles)
00083             ob.__ac_local_roles__ = local_roles
00084             return 1
00085     # Edit the roles.
00086     roles = list(roles)
00087     changed = 0
00088     for role in managed_roles:
00089         if role in grant_roles and role not in roles:
00090             # Add one role for this group.
00091             roles.append(role)
00092             changed = 1
00093         elif role not in grant_roles and role in roles:
00094             # Remove one role for this group.
00095             roles.remove(role)
00096             changed = 1
00097     if changed:
00098         if not roles and local_roles.has_key(group):
00099             del local_roles[group]
00100         else:
00101             local_roles[group] = roles
00102         ob.__ac_local_roles__ = local_roles
00103     return changed
00104 
security.declarePublic('Message')

Here is the caller graph for this function:

def DCWorkflow.utils.modifyRolesForPermission (   ob,
  pname,
  roles 
)
Modifies multiple role to permission mappings.  roles is a list to
acquire, a tuple to not acquire.

Definition at line 50 of file utils.py.

00050 
00051 def modifyRolesForPermission(ob, pname, roles):
00052     '''
00053     Modifies multiple role to permission mappings.  roles is a list to
00054     acquire, a tuple to not acquire.
00055     '''
00056     # This mimics what AccessControl/Role.py does.
00057     data = ()
00058     for perm in ac_inherited_permissions(ob, 1):
00059         name, value = perm[:2]
00060         if name == pname:
00061             data = value
00062             break
00063     p = Permission(pname, data, ob)
00064     if p.getRoles() != roles:
00065         p.setRoles(roles)
00066         return 1
00067     return 0

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

tuple DCWorkflow.utils._dtmldir = os.path.join( package_home( globals() ), 'dtml' )

Definition at line 28 of file utils.py.

tuple DCWorkflow.utils._xmldir = os.path.join( package_home( globals() ), 'xml' )

Definition at line 29 of file utils.py.

tuple DCWorkflow.utils.Message = _MessageFactory('cmf_default')

Definition at line 105 of file utils.py.

tuple DCWorkflow.utils.security = ModuleSecurityInfo('Products.DCWorkflow.utils')

Definition at line 26 of file utils.py.