예제 #1
0
파일: extract.py 프로젝트: 01-/storyweb
def extract_entities(parent):
    from storyweb.queue import index
    for offset, child in extract_multi(parent):
        log.info("Extraced: %r in %r", child, parent)
        data = {
            'offset': offset,
            'child': child
        }
        link = Link.find(parent, child)
        if link is None:
            link = Link()
        else:
            data['status'] = link.status
        link.save(data, parent, child.author)
    
    index.delay(parent.id)
예제 #2
0
파일: queue.py 프로젝트: msoftware/storyweb
def extract(card_id):
    parent = Card.by_id(card_id)
    if parent.category != Card.ARTICLE:
        log.info('Not extracting entities from "%s"...', parent.title)
        return
    log.info('Extracting entities from "%s"...', parent.title)
    try:
        for offset, child in extract_entities(parent.text):
            data = {
                'offset': offset,
                'child': child
            }
            link = Link.find(parent, child)
            if link is None:
                link = Link()
            else:
                data['status'] = link.status
            link.save(data, parent, child.author)
        index.delay(card_id)
        db.session.commit()
    except Exception, e:
        log.exception(e)
예제 #3
0
def delete(parent_id, id):
    authz.require(authz.logged_in())
    link = obj_or_404(Link.by_id(id, parent_id=parent_id))
    db.session.delete(link)
    db.session.commit()
    raise Gone()
예제 #4
0
def update(parent_id, id):
    authz.require(authz.logged_in())
    link = obj_or_404(Link.by_id(id, parent_id=parent_id))
    link.save(request_data(), link.parent, g.user)
    db.session.commit()
    return jsonify(link)
예제 #5
0
def view(parent_id, id):
    authz.require(authz.logged_in())
    link = obj_or_404(Link.by_id(id, parent_id=parent_id))
    return jsonify(link)
예제 #6
0
def delete(parent_id, id):
    authz.require(authz.logged_in())
    link = obj_or_404(Link.by_id(id, parent_id=parent_id))
    db.session.delete(link)
    db.session.commit()
    raise Gone()
예제 #7
0
def update(parent_id, id):
    authz.require(authz.logged_in())
    link = obj_or_404(Link.by_id(id, parent_id=parent_id))
    link.save(request_data(), link.parent, g.user)
    db.session.commit()
    return jsonify(link)
예제 #8
0
def view(parent_id, id):
    authz.require(authz.logged_in())
    link = obj_or_404(Link.by_id(id, parent_id=parent_id))
    return jsonify(link)
예제 #9
0
def create(parent_id):
    authz.require(authz.logged_in())
    card = obj_or_404(Card.by_id(parent_id))
    reference = Link().save(request_data(), card, g.user)
    db.session.commit()
    return jsonify(reference, status=201)