Changeset 4124


Ignore:
Timestamp:
10 May 2009, 14:53:46 (16 years ago)
Author:
uli
Message:

Add some roles.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • waeup/branches/ulif-rewrite/src/waeup/permissions.py

    r4069 r4124  
    11import grok
     2from zc.sourcefactory.basic import BasicSourceFactory
    23
    34class ManageUniversity(grok.Permission):
     
    1011    grok.name('waeup.facultyread')
    1112
     13class PortalUser(grok.Role):
     14    grok.name('waeup.PortalUser')
     15    grok.permissions('waeup.facultyread')
     16
     17class PortalManager(grok.Role):
     18    grok.name('waeup.PortalManager')
     19    grok.permissions('waeup.manageUniversity', 'waeup.manageUsers')
     20
     21def getRoles():
     22    app = grok.getSite()
     23    app = None
     24    manager = None
     25    if app is not None:
     26        from zope.securitypolicy.interfaces import IRolePermissionManager
     27        manager = IRolePermissionManager(app, None)
     28    else:
     29        from zope.securitypolicy.rolepermission import (
     30            rolePermissionManager as manager)
     31    role_permission_map =  manager.getRolesAndPermissions()
     32    result = dict()
     33    for item in role_permission_map:
     34        if not item[1].startswith('waeup.'):
     35            # Ignore non-WAeUP roles...
     36            continue
     37        result[item[1]] = True
     38    return sorted(result.keys())
     39
     40class RoleSource(BasicSourceFactory):
     41    def getValues(self):
     42        return getRoles()
     43    def getTitle(self, value):
     44        if isinstance(value, basestring):
     45            return value.split('.', 2)[1]
Note: See TracChangeset for help on using the changeset viewer.