当前位置: 首页>>代码示例>>Python>>正文


Python Project.by_slug方法代码示例

本文整理汇总了Python中grano.model.Project.by_slug方法的典型用法代码示例。如果您正苦于以下问题:Python Project.by_slug方法的具体用法?Python Project.by_slug怎么用?Python Project.by_slug使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在grano.model.Project的用法示例。


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

示例1: decode

# 需要导入模块: from grano.model import Project [as 别名]
# 或者: from grano.model.Project import by_slug [as 别名]
 def decode(self, node, cstruct):
     if isinstance(cstruct, Project):
         return cstruct
     if isinstance(cstruct, basestring):
         return Project.by_slug(cstruct)
     if isinstance(cstruct, dict):
         if cstruct.get('slug'):
             return Project.by_slug(cstruct.get('slug'))
     return None
开发者ID:ahurriyetoglu,项目名称:grano,代码行数:11,代码来源:references.py

示例2: es_index

# 需要导入模块: from grano.model import Project [as 别名]
# 或者: from grano.model.Project import by_slug [as 别名]
 def es_index(project=None):
     """ Re-index all entities in the system, or those in a project. """
     if project is not None:
         project = Project.by_slug(project)
         if project is None:
             raise ValueError("Project not found.")
     script_indexer.index_project(project=project)
开发者ID:c0ns0le,项目名称:grano-elasticsearch,代码行数:9,代码来源:base.py

示例3: schema_import

# 需要导入模块: from grano.model import Project [as 别名]
# 或者: from grano.model.Project import by_slug [as 别名]
def schema_import(project, path):
    """ Load a schema specification from a YAML file. """
    pobj = Project.by_slug(project)
    if pobj is None:
        pobj = save_project({"slug": project, "label": project, "author": console_account()})
    with open(path, "r") as fh:
        import_schema(pobj, fh)
开发者ID:nimblemachine,项目名称:grano,代码行数:9,代码来源:manage.py

示例4: update

# 需要导入模块: from grano.model import Project [as 别名]
# 或者: from grano.model.Project import by_slug [as 别名]
def update(slug):
    project = object_or_404(Project.by_slug(slug))
    authz.require(authz.project_manage(project))
    data = request_data({'author': request.account})
    project = projects.save(data, project=project)
    db.session.commit()
    return jsonify(project)
开发者ID:01-,项目名称:grano,代码行数:9,代码来源:projects_api.py

示例5: delete

# 需要导入模块: from grano.model import Project [as 别名]
# 或者: from grano.model.Project import by_slug [as 别名]
def delete(slug, id):
    project = object_or_404(Project.by_slug(slug))
    authz.require(authz.project_manage(project))
    permission = object_or_404(Permission.by_project_and_id(project, id))
    permissions.delete(permission)
    db.session.commit()
    raise Gone()
开发者ID:01-,项目名称:grano,代码行数:9,代码来源:permissions_api.py

示例6: suggest_type

# 需要导入模块: from grano.model import Project [as 别名]
# 或者: from grano.model.Project import by_slug [as 别名]
def suggest_type(slug):
    project = object_or_404(Project.by_slug(slug))
    authz.require(authz.project_read(project))

    prefix = '%%%s%%' % request.args.get('prefix', '')
    log.info("Suggesting types in %s: %r", project.slug, prefix)

    q = db.session.query(Schema)
    q = q.filter(Schema.obj == 'entity')
    q = q.filter(Schema.hidden == False) # noqa
    q = q.filter(Schema.project == project)
    q = q.filter(or_(Schema.label.ilike(prefix), Schema.name.ilike(prefix)))
    q = q.limit(get_limit(default=5))

    matches = []
    for schema in q:
        matches.append({
            'name': schema.label,
            'id': '/%s/%s' % (slug, schema.name)
        })
    return jsonify({
        "code": "/api/status/ok",
        "status": "200 OK",
        "prefix": request.args.get('prefix', ''),
        "result": matches
    })
开发者ID:01-,项目名称:grano,代码行数:28,代码来源:reconcile_api.py

示例7: create

# 需要导入模块: from grano.model import Project [as 别名]
# 或者: from grano.model.Project import by_slug [as 别名]
def create(slug):
    project = object_or_404(Project.by_slug(slug))
    authz.require(authz.project_manage(project))
    data = request_data({'project': project})
    permission = permissions.save(data)
    db.session.commit()
    return jsonify(permission, status=201)
开发者ID:01-,项目名称:grano,代码行数:9,代码来源:permissions_api.py

示例8: suggest_property

# 需要导入模块: from grano.model import Project [as 别名]
# 或者: from grano.model.Project import by_slug [as 别名]
def suggest_property(slug):
    project = object_or_404(Project.by_slug(slug))
    authz.require(authz.project_read(project))

    prefix = '%%%s%%' % request.args.get('prefix', '')
    q = db.session.query(Attribute)
    q = q.join(Schema)
    q = q.filter(Schema.obj=='entity')
    q = q.filter(Schema.project==project)
    q = q.filter(or_(Attribute.label.ilike(prefix), Attribute.name.ilike(prefix)))
    q = q.limit(get_limit(default=5))

    matches = []
    for attribute in q:
        matches.append({
            'name': attribute.label,
            'n:type': {
                'id': '/properties/property',
                'name': 'Property'
            },
            'id': attribute.name
        })
    return jsonify({
        "code" : "/api/status/ok",
        "status" : "200 OK",
        "prefix" : request.args.get('prefix', ''),
        "result" : matches
        })
开发者ID:ashwinsekar18,项目名称:grano-reconcile,代码行数:30,代码来源:view.py

示例9: reconcile

# 需要导入模块: from grano.model import Project [as 别名]
# 或者: from grano.model.Project import by_slug [as 别名]
def reconcile(slug):
    """
    Reconciliation API, emulates Google Refine API. See: 
    http://code.google.com/p/google-refine/wiki/ReconciliationServiceApi
    """
    project = object_or_404(Project.by_slug(slug))
    authz.require(authz.project_read(project))

    # TODO: Add proper support for types and namespacing.
    data = request.args.copy()
    data.update(request.form.copy())
    if 'query' in data:
        # single 
        q = data.get('query')
        if q.startswith('{'):
            try:
                q = json.loads(q)
            except ValueError:
                raise BadRequest()
        else:
            q = data
        return jsonify(reconcile_op(project, q))
    elif 'queries' in data:
        # multiple requests in one query
        qs = data.get('queries')
        try:
            qs = json.loads(qs)
        except ValueError:
            raise BadRequest()
        queries = {}
        for k, q in qs.items():
            queries[k] = reconcile_op(project, q)
        return jsonify(queries)
    else:
        return reconcile_index(project)
开发者ID:ashwinsekar18,项目名称:grano-reconcile,代码行数:37,代码来源:view.py

示例10: view

# 需要导入模块: from grano.model import Project [as 别名]
# 或者: from grano.model.Project import by_slug [as 别名]
def view(slug, name):
    project = object_or_404(Project.by_slug(slug))
    authz.require(authz.project_read(project))
    if not project.private:
        validate_cache(last_modified=project.updated_at)
    schema = object_or_404(Schema.by_name(project, name))
    return jsonify(schema)
开发者ID:ahurriyetoglu,项目名称:grano,代码行数:9,代码来源:schemata_api.py

示例11: delete

# 需要导入模块: from grano.model import Project [as 别名]
# 或者: from grano.model.Project import by_slug [as 别名]
def delete(slug, name):
    project = object_or_404(Project.by_slug(slug))
    authz.require(authz.project_manage(project))
    schema = object_or_404(Schema.by_name(project, name))
    schemata.delete(schema)
    db.session.commit()
    raise Gone()
开发者ID:ahurriyetoglu,项目名称:grano,代码行数:9,代码来源:schemata_api.py

示例12: create

# 需要导入模块: from grano.model import Project [as 别名]
# 或者: from grano.model.Project import by_slug [as 别名]
def create(slug):
    project = object_or_404(Project.by_slug(slug))
    authz.require(authz.project_manage(project))
    data = request_data({"project": project})
    schema = schemata.save(data)
    db.session.commit()
    return jsonify(schema, status=201)
开发者ID:4bic,项目名称:grano,代码行数:9,代码来源:schemata_api.py

示例13: suggest_property

# 需要导入模块: from grano.model import Project [as 别名]
# 或者: from grano.model.Project import by_slug [as 别名]
def suggest_property(slug):
    project = object_or_404(Project.by_slug(slug))
    authz.require(authz.project_read(project))

    prefix = "%%%s%%" % request.args.get("prefix", "")
    log.info("Suggesting property names in %s: %r", project.slug, prefix)

    q = db.session.query(Attribute)
    q = q.join(Schema)
    q = q.filter(Schema.obj == "entity")
    q = q.filter(Schema.project == project)
    q = q.filter(or_(Attribute.label.ilike(prefix), Attribute.name.ilike(prefix)))
    q = q.limit(get_limit(default=5))

    matches = []
    for attribute in q:
        matches.append(
            {
                "name": attribute.label,
                "n:type": {"id": "/properties/property", "name": "Property"},
                "id": attribute.name,
            }
        )
    return jsonify(
        {"code": "/api/status/ok", "status": "200 OK", "prefix": request.args.get("prefix", ""), "result": matches}
    )
开发者ID:pudo-attic,项目名称:grano-reconcile,代码行数:28,代码来源:view.py

示例14: index

# 需要导入模块: from grano.model import Project [as 别名]
# 或者: from grano.model.Project import by_slug [as 别名]
def index(slug):
    project = object_or_404(Project.by_slug(slug))
    authz.require(authz.project_read(project))
    validate_cache(last_modified=project.updated_at)
    query = Schema.all()
    query = query.filter_by(project=project)
    pager = Pager(query, slug=slug)
    return jsonify(pager, index=not arg_bool("full"))
开发者ID:4bic,项目名称:grano,代码行数:10,代码来源:schemata_api.py

示例15: facet_schema_list

# 需要导入模块: from grano.model import Project [as 别名]
# 或者: from grano.model.Project import by_slug [as 别名]
def facet_schema_list(obj, facets):
    results = []
    project = Project.by_slug('openinterests')
    for facet in facets:
        schema = Schema.by_name(project, facet.get('term'))
        if schema is not None and not schema.hidden:
            results.append((schema, facet.get('count')))
    return results
开发者ID:IuliiSe,项目名称:openinterests.eu,代码行数:10,代码来源:util.py


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