'Returns a list of the realm entities which a user can access for
the given table.
@param tablename: the tablename
@param method: the method
@return: a list of pe_ids or None (for no restriction)'

def permitted_realms(self, tablename, method='read'):

    if (not self.entity_realm):
        return
    auth = self.auth
    sr = auth.get_system_roles()
    user = auth.user
    if auth.is_logged_in():
        realms = user.realms
        if (sr.ADMIN in realms):
            return None
        delegations = user.delegations
    else:
        realms = Storage({sr.ANONYMOUS: None})
        delegations = Storage()
    racl = self.required_acl([method])
    request = current.request
    acls = self.applicable_acls(racl, realms=realms, delegations=delegations, c=request.controller, f=request.function, t=tablename)
    if ('ANY' in acls):
        return None
    entities = []
    for entity in acls:
        acl = acls[entity]
        if ((acl[0] & racl) == racl):
            entities.append(entity)
    return entities
