• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python authz.require函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中nomenklatura.authz.require函数的典型用法代码示例。如果您正苦于以下问题:Python require函数的具体用法?Python require怎么用?Python require使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了require函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: create

def create():
    data = request_data()
    dataset = Dataset.from_form(data)
    authz.require(authz.dataset_edit(dataset))
    entity = Entity.create(dataset, data, request.account)
    db.session.commit()
    return redirect(url_for('.view', id=entity.id))
开发者ID:IdahoInstitute,项目名称:nomenklatura,代码行数:7,代码来源:entities.py


示例2: edit

def edit(dataset):
    dataset = Dataset.find(dataset)
    authz.require(authz.dataset_manage(dataset))
    html = render_template('dataset/edit.html',
                           dataset=dataset,
                           algorithms=get_algorithms())
    return htmlfill.render(html, defaults=dataset.as_dict())
开发者ID:okfn,项目名称:nomenklatura,代码行数:7,代码来源:dataset.py


示例3: match

def match(dataset, link, random=False):
    dataset = Dataset.find(dataset)
    authz.require(authz.dataset_edit(dataset))
    link = Link.find(dataset, link)
    random = random or request.args.get('random')=='True'
    choices = match_op(link.key, dataset,
            query=request.args.get('query'))
    pager = Pager(choices, '.match',
        dataset=dataset.name, link=link.id,
        limit=10)

    # HACK: Fetch only the values on the selected page.
    value_objs = Value.id_map(dataset, map(lambda (c,v,s): v,
        pager.query[pager.offset:pager.offset+pager.limit]))
    for i, (c,v,s) in enumerate(pager.query):
        if v in value_objs:
            pager.query[i] = (c, value_objs.get(v), s)

    html = render_template('link/match.html',
            dataset=dataset, link=link, choices=pager,
            random=random)
    choice = 'INVALID' if link.is_invalid else link.value_id
    if len(choices) and choice is None:
        c, v, s = choices[0]
        choice = 'INVALID' if s <= 50 else v
    return htmlfill.render(html, force_defaults=False,
            defaults={'choice': choice,
                      'value': link.key,
                      'query': request.args.get('query', ''),
                      'random': random})
开发者ID:okfn,项目名称:nomenklatura,代码行数:30,代码来源:link.py


示例4: match

def match(dataset, alias, random=False):
    dataset = Dataset.find(dataset)
    authz.require(authz.dataset_edit(dataset))
    alias = Alias.find(dataset, alias)
    random = random or request.args.get('random')=='True'
    choices = match_op(alias.name, dataset,
            query=request.args.get('query'))
    pager = Pager(choices, '.match',
        dataset=dataset.name, alias=alias.id,
        limit=10)

    # HACK: Fetch only the entities on the selected page.
    entities = Entity.id_map(dataset, map(lambda (c,e,s): e,
        pager.query[pager.offset:pager.offset+pager.limit]))
    for i, (c,e,s) in enumerate(pager.query):
        if e in entities:
            pager.query[i] = (c, entities.get(e), s)

    html = render_template('alias/match.html',
            dataset=dataset, alias=alias, choices=pager,
            random=random)
    choice = 'INVALID' if alias.is_invalid else alias.entity_id
    if len(choices) and choice is None:
        c, e, s = choices[0]
        choice = 'INVALID' if s <= 50 else e.id
    return htmlfill.render(html, force_defaults=False,
            defaults={'choice': choice,
                      'name': alias.name,
                      'query': request.args.get('query', ''),
                      'random': random})
开发者ID:OpenRefine,项目名称:nomenklatura,代码行数:30,代码来源:alias.py


示例5: create

def create():
    authz.require(authz.dataset_create())
    data = request_content()
    try:
        dataset = Dataset.create(data, request.account)
        db.session.commit()
        return redirect(url_for('.view', dataset=dataset.name))
    except Invalid, inv:
        return handle_invalid(inv, new, data=data)
开发者ID:okfn,项目名称:nomenklatura,代码行数:9,代码来源:dataset.py


示例6: upload

def upload(dataset):
    dataset = Dataset.find(dataset)
    authz.require(authz.dataset_edit(dataset))
    file_ = request.files.get('file')
    if not file_ or not file_.filename:
        err = {'file': "You need to upload a file"}
        raise Invalid("No file.", None, None, error_dict=err)
    upload = Upload.create(dataset, request.account, file_)
    db.session.commit()
    return jsonify(upload)
开发者ID:IdahoInstitute,项目名称:nomenklatura,代码行数:10,代码来源:upload.py


示例7: upload

def upload(dataset):
    dataset = Dataset.find(dataset)
    authz.require(authz.dataset_edit(dataset))
    file_ = request.files.get('file')
    if not file_ or not file_.filename:
        inv = Invalid("No file.", None, None,
                      error_dict={'file': "You need to upload a file"})
        raise inv
    upload = upload_file(dataset, file_, request.account)
    return redirect(url_for('.map', dataset=dataset.name, id=upload.id))
开发者ID:gabelula,项目名称:nomenklatura,代码行数:10,代码来源:upload.py


示例8: match_random

def match_random(dataset):
    dataset = Dataset.find(dataset)
    authz.require(authz.dataset_edit(dataset))
    aliases = Alias.all_unmatched(dataset)
    count = aliases.count()
    if count == 0:
        return redirect(url_for('dataset.view',
            dataset=dataset.name))
    alias = aliases.offset(randint(0, count-1)).first()
    return redirect(url_for('.match', dataset=dataset.name, alias=alias.id,
                            random=True))
开发者ID:OpenRefine,项目名称:nomenklatura,代码行数:11,代码来源:alias.py


示例9: upload

def upload(dataset):
    dataset = Dataset.find(dataset)
    authz.require(authz.dataset_edit(dataset))
    file_ = request.files.get('file')
    if not file_ or not file_.filename:
        inv = Invalid("No file.", None, None,
                error_dict={'file': "You need to upload a file"})
        return handle_invalid(inv, form, data={},
                args=[dataset.name])
    sig = upload_file(dataset, file_)
    return redirect(url_for('.map', dataset=dataset.name, sig=sig))
开发者ID:OpenRefine,项目名称:nomenklatura,代码行数:11,代码来源:upload.py


示例10: update

def update(dataset):
    dataset = Dataset.find(dataset)
    authz.require(authz.dataset_manage(dataset))
    data = request_content()
    try:
        dataset.update(data)
        db.session.commit()
        flash("Updated %s" % dataset.label, "success")
        return redirect(url_for(".view", dataset=dataset.name))
    except Invalid, inv:
        return handle_invalid(inv, edit, args=[dataset.name], data=data)
开发者ID:csenger,项目名称:nomenklatura,代码行数:11,代码来源:dataset.py


示例11: match_save

def match_save(dataset, alias):
    dataset = Dataset.find(dataset)
    authz.require(authz.dataset_edit(dataset))
    alias = Alias.find(dataset, alias)
    random = request.form.get('random')=='True'
    data = request_content()
    try:
        alias.match(dataset, data, request.account)
        db.session.commit()
    except Invalid, inv:
        return handle_invalid(inv, match, data=data,
                              args=[dataset.name, alias.id, random])
开发者ID:OpenRefine,项目名称:nomenklatura,代码行数:12,代码来源:alias.py


示例12: submit

def submit(dataset, sig):
    dataset = Dataset.find(dataset)
    authz.require(authz.dataset_edit(dataset))
    data = request_content()
    value_col = data.get('value') or None
    link_col = data.get('link') or None
    if not (value_col or link_col):
        flash('You need to pick either a link or value column!', 'error')
        return map(dataset.name, sig)
    import_upload.delay(dataset.name, sig, request.account.id,
            value_col, link_col)
    flash('Loading data...', 'success')
    return redirect(url_for('dataset.view', dataset=dataset.name))
开发者ID:okfn,项目名称:nomenklatura,代码行数:13,代码来源:upload.py


示例13: update

def update(dataset, value):
    dataset = Dataset.find(dataset)
    authz.require(authz.dataset_edit(dataset))
    value = Value.find(dataset, value)
    data = request_content()
    try:
        value.update(data, request.account)
        db.session.commit()
        flash("Updated %s" % value.value, 'success')
        return redirect(url_for('.view', dataset=dataset.name, value=value.id))
    except Invalid, inv:
        return handle_invalid(inv, view, data=data,
                              args=[dataset.name, value.id])
开发者ID:csenger,项目名称:nomenklatura,代码行数:13,代码来源:value.py


示例14: submit

def submit(dataset, id):
    dataset = Dataset.find(dataset)
    authz.require(authz.dataset_edit(dataset))
    data = request_content()
    entity_col = data.get('entity') or None
    alias_col = data.get('alias') or None
    if not (entity_col or alias_col):
        flash('You need to pick either a alias or entity column!', 'error')
        return map(dataset.name, id)
    import_upload.delay(dataset.name, id, request.account.id,
                        entity_col, alias_col)
    flash('Loading data...', 'success')
    return redirect(url_for('dataset.view', dataset=dataset.name))
开发者ID:imclab,项目名称:nomenklatura,代码行数:13,代码来源:upload.py


示例15: update

def update(dataset, entity):
    dataset = Dataset.find(dataset)
    authz.require(authz.dataset_edit(dataset))
    entity = Entity.find(dataset, entity)
    data = request_content()
    try:
        entity.update(data, request.account)
        db.session.commit()
        flash("Updated %s" % entity.display_name, 'success')
        return redirect(url_for('.view', dataset=dataset.name, entity=entity.id))
    except Invalid, inv:
        return handle_invalid(inv, view, data=data,
                              args=[dataset.name, entity.id])
开发者ID:OpenRefine,项目名称:nomenklatura,代码行数:13,代码来源:entity.py


示例16: create

def create(dataset):
    dataset = Dataset.find(dataset)
    authz.require(authz.dataset_edit(dataset))
    data = request_content()
    try:
        value = Value.create(dataset, data, request.account)
        db.session.commit()
        return redirect(url_for('.view',
            dataset=dataset.name,
            value=value.id))
    except Invalid, inv:
        return handle_invalid(inv, view_dataset, data=data, 
                              args=[dataset.name])
开发者ID:csenger,项目名称:nomenklatura,代码行数:13,代码来源:value.py


示例17: match_save

def match_save(dataset, link):
    dataset = Dataset.find(dataset)
    authz.require(authz.dataset_edit(dataset))
    link = Link.find(dataset, link)
    random = request.form.get('random')=='True'
    data = request_content()
    try:
        link.match(dataset, data, request.account)
        if link.value is not None:
            add_candidate_to_cache(dataset, link.key, link.value.id)
        db.session.commit()
    except Invalid, inv:
        return handle_invalid(inv, match, data=data, 
                              args=[dataset.name, link.id, random])
开发者ID:okfn,项目名称:nomenklatura,代码行数:14,代码来源:link.py


示例18: merge

def merge(dataset, value):
    dataset = Dataset.find(dataset)
    authz.require(authz.dataset_edit(dataset))
    value = Value.find(dataset, value)
    data = request_content()
    try:
        target = value.merge_into(data, request.account)
        flush_cache(dataset)
        db.session.commit()
        flash("Merged %s" % value.value, 'success')
        return redirect(url_for('.view', dataset=dataset.name,
                        value=target.id))
    except Invalid, inv:
        print inv
        return handle_invalid(inv, view, data=data,
                              args=[dataset.name, value.id])
开发者ID:okfn,项目名称:nomenklatura,代码行数:16,代码来源:value.py


示例19: process

def process(dataset, id):
    dataset = Dataset.find(dataset)
    authz.require(authz.dataset_edit(dataset))
    upload = Upload.find(dataset, id)
    mapping = request_data()
    mapping['reviewed'] = mapping.get('reviewed') or False
    mapping['columns'] = mapping.get('columns', {})
    fields = mapping['columns'].values()
    for header in mapping['columns'].keys():
        if header not in upload.tab.headers:
            raise Invalid("Invalid header: %s" % header, None, None)    

    if 'name' not in fields and 'id' not in fields:
        raise Invalid("You have not selected a field that definies entity names.", None, None)

    import_upload.delay(upload.id, request.account.id, mapping)
    return jsonify({'status': 'Loading data...'})
开发者ID:IdahoInstitute,项目名称:nomenklatura,代码行数:17,代码来源:upload.py


示例20: match

def match(dataset, link, random=False):
    dataset = Dataset.find(dataset)
    authz.require(authz.dataset_edit(dataset))
    link = Link.find(dataset, link)
    random = random or request.args.get('random')=='True'
    choices = match_op(link.key, dataset,
            query=request.args.get('query'))
    pager = Pager(choices, '.match',
        dataset=dataset.name, link=link.id,
        limit=10)
    html = render_template('link/match.html',
            dataset=dataset, link=link, choices=pager,
            random=random)
    choice = 'INVALID' if link.is_invalid else link.value_id
    if len(choices):
        choice = choices[0][1].id if choice is None else choice
    return htmlfill.render(html, force_defaults=False,
            defaults={'choice': choice,
                      'value': link.key,
                      'query': request.args.get('query', ''),
                      'random': random})
开发者ID:csenger,项目名称:nomenklatura,代码行数:21,代码来源:link.py



注:本文中的nomenklatura.authz.require函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python model.Dataset类代码示例发布时间:2022-05-27
下一篇:
Python lasagne.NeuralNet类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap