

def sources(action):
    if (not hasattr(request, 'auth_sources')):
        request.auth_sources = {
            READ: set(),
            WRITE: set(),
        }
        if is_admin():
            for (source_id,) in Source.all_ids():
                request.auth_sources[READ].add(source_id)
                request.auth_sources[WRITE].add(source_id)
        else:
            q = Permission.all()
            q = q.filter(Permission.role_id.in_(request.auth_roles))
            q = q.filter((Permission.resource_type == Permission.SOURCE))
            for perm in q:
                if perm.read:
                    request.auth_sources[READ].add(perm.resource_id)
                if (perm.write and request.logged_in):
                    request.auth_sources[WRITE].add(perm.resource_id)
    return list(request.auth_sources.get(action, []))

dataset/ETHPy150Open pudo/aleph/aleph/authz.py sources/original