def privileges_grant(name,
        object_name,
        object_type,
        privileges=None,
        grant_option=None,
        prepend='public',
        maintenance_db=None,
        user=None,
        host=None,
        port=None,
        password=None,
        runas=None):
    object_type, privileges, _privs = _mod_priv_opts(object_type, privileges)

    _validate_privileges(object_type, _privs, privileges)

    if has_privileges(name, object_name, object_type, privileges,
        prepend=prepend, maintenance_db=maintenance_db, user=user,
            host=host, port=port, password=password, runas=runas):
        log.info('The object: %s of type: %s already has privileges: %s set',
            object_name, object_type, privileges)
        return False

    _grants = ','.join(_privs)

    if object_type in ['table', 'sequence']:
        on_part = '{0}.{1}'.format(prepend, object_name)
    else:
        on_part = object_name

    if grant_option:
        if object_type == 'group':
            query = 'GRANT {0} TO {1} WITH ADMIN OPTION'.format(
                object_name, name)
        else:
            query = 'GRANT {0} ON {1} {2} TO {3} WITH GRANT OPTION'.format(
                _grants, object_type.upper(), on_part, name)
    else:
        if object_type == 'group':
            query = 'GRANT {0} TO {1}'.format(object_name, name)
        else:
            query = 'GRANT {0} ON {1} {2} TO {3}'.format(
                _grants, object_type.upper(), on_part, name)

    ret = _psql_prepare_and_run(['-c', query],
                                user=user,
                                host=host,
                                port=port,
                                maintenance_db=maintenance_db,
                                password=password,
                                runas=runas)

    return ret['retcode'] == 0
Test that CMSSitemap object contains only published,public (login_required=False) pages
dataset/ETHPy150Open saltstack/salt/salt/modules/postgres.py/privileges_grant--crossover with--dataset/ETHPy150Open divio/django-cms/cms/tests/test_page.py/PagesTestCase.test_sitemap_login_required_pages