'Returns the realm (list of pe_ids) that this user can manage
or raises a permission error if the user is not logged in'

def get_realm(self):

    auth = current.auth
    system_roles = auth.get_system_roles()
    ORG_ADMIN = system_roles.ORG_ADMIN
    ADMIN = system_roles.ADMIN
    if auth.user:
        realms = auth.user.realms
    else:
        auth.permission.fail()
    if (ADMIN in realms):
        return realms[ADMIN]
    elif (ORG_ADMIN in realms):
        return realms[ORG_ADMIN]
    else:
        auth.permission.fail()
