'Get the IDs of the session roles by their UIDs, and store them
in the current session, as these IDs should never change.'

def get_system_roles(self):

    s3 = current.session.s3
    try:
        system_roles = s3.system_roles
    except:
        s3 = Storage()
    else:
        if system_roles:
            return system_roles
    gtable = self.settings.table_group
    if (gtable is not None):
        S3_SYSTEM_ROLES = self.S3_SYSTEM_ROLES
        query = ((gtable.deleted != True) & gtable.uuid.belongs(S3_SYSTEM_ROLES.values()))
        rows = current.db(query).select(gtable.id, gtable.uuid)
        system_roles = Storage([(role.uuid, role.id) for role in rows])
    else:
        system_roles = Storage([(uid, None) for uid in S3_SYSTEM_ROLES])
    s3.system_roles = system_roles
    return system_roles
