Ignore:
Timestamp:
20 May 2011, 08:52:48 (13 years ago)
Author:
uli
Message:

Zope roles come with a title attribute. Start making use of it and simplify role lookup in w.s.permissions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/interfaces.py

    r6147 r6157  
    99from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
    1010
    11 
    1211class FatalCSVError(Exception):
    1312    """Some row could not be processed.
     
    2423class RoleSource(BasicSourceFactory):
    2524    def getValues(self):
     25        # late import: in interfaces we should not import local modules
     26        from waeup.sirp.permissions import getWAeUPRoleNames
     27        return getWAeUPRoleNames()
     28
     29    def getTitle(self, value):
     30        # late import: in interfaces we should not import local modules
    2631        from waeup.sirp.permissions import getRoles
    27         return getRoles()
    28     def getTitle(self, value):
    29         if isinstance(value, basestring):
    30             return value.split('.', 2)[1]
     32        roles = dict(getRoles())
     33        if value in roles.keys():
     34            title = roles[value].title
     35        if '.' in title:
     36            title = title.split('.', 2)[1]
     37        return title
    3138
    3239class IWAeUPObject(Interface):
Note: See TracChangeset for help on using the changeset viewer.