Ejemplo n.º 1
0
def view(id):
    authz.require(authz.system_edit())
    pairing = obj_or_404(Pairing.by_id(id))
    return jsonify(
        {
            "status": "ok",
            "left": EntityQuery.by_id(pairing.left_id),
            "right": EntityQuery.by_id(pairing.right_id),
            "pairing": pairing,
        }
    )
Ejemplo n.º 2
0
def update(id):
    authz.require(authz.system_edit())
    entity = obj_or_404(EntityQuery.by_id(id))
    context = Context.create(current_user, {})
    entity.update(request_data(), context)
    db.session.commit()
    return redirect(url_for(".view", id=entity.id))
Ejemplo n.º 3
0
 def deserialize(self, value):
     from nomenklatura.model.entity import Entity
     from nomenklatura.query import EntityQuery
     if isinstance(value, Entity):
         return value
     ent = EntityQuery.by_id(value)
     # if ent is None:
     #    raise TypeError("Entity does not exist: %r" % value)
     return ent
Ejemplo n.º 4
0
def enrich_entity(root, entity_id, spider=None):
    entity = EntityQuery.by_id(entity_id)
    if entity is None:
        log.error('Entity does not exist: %s', entity_id)
        return

    for name, cls in get_spiders().items():
        if spider is not None and spider != name:
            continue

        try:
            inst = cls()
            inst.lookup(root, entity)
            db.session.commit()
        except Exception, e:
            log.exception(e)
            db.session.rollback()
Ejemplo n.º 5
0
def view(id):
    authz.require(authz.system_read())
    entity = obj_or_404(EntityQuery.by_id(id))
    return jsonify(entity)