コード例 #1
0
ファイル: imports.py プロジェクト: mychapati/nomenklatura
def load_upload(context_id):
    context = Context.by_id(context_id)
    if not context.resource_name or not context.resource_mapping:
        log.warning("No resource associated with context: %r", context)
        return
    context.active = False
    db.session.commit()

    source, table = get_table(context)
    set_state(source, 'loading')
    handler = get_logger(source.package, context)

    try:
        for record in table.records():
            try:
                load_entity(context, context.resource_mapping, record)
            except DataException, de:
                log.error("Cannot convert '%s' to %s for attribute '%s': %s",
                          de.value, de.data_type, de.attribute, de.message)
            except Exception, e:
                log.exception(e)
コード例 #2
0
ファイル: imports.py プロジェクト: mychapati/nomenklatura
def analyze_upload(context_id):
    context = Context.by_id(context_id)
    if not context.resource_name:
        log.warning("No resource associated with context: %r", context)
        return
    source, target = get_table(context)
    set_state(source, 'analyzing')
    handler = get_logger(source.package, context)

    try:
        log.info("Extracting tabular data...")
        if not source.exists():
            log.warning("Source data does not exist: %r",
                        context.resource_name)
            return
        operator = TableExtractOperator(None, 'temp', {})
        operator.transform(source, target)
        set_state(source, 'analyzed')
    except Exception, e:
        log.error(unicode(e))
        set_state(source, 'failed')
コード例 #3
0
def update(id):
    authz.require(authz.system_edit())
    context = obj_or_404(Context.by_id(id))
    context.update(request_data())
    db.session.commit()
    return redirect(url_for('.view', id=context.id))
コード例 #4
0
def view(id):
    authz.require(authz.system_read())
    context = obj_or_404(Context.by_id(id))
    return jsonify(context)