예제 #1
0
    if p['id'] == id:
        break
  else:
    log.error('Could not find resource ' + id)
    raise NotFound(_('Resource was not found.'))

  upload = uploader.S3Upload(data_dict)

  pkg_dict['resources'][n] = data_dict

  try:
    context['defer_commit'] = True
    context['use_cache'] = False
    pkg_dict = _get_action('package_update')(context, pkg_dict)
    context.pop('defer_commit')
  except ValidationError, e:
    errors = e.error_dict['resources'][n]
    raise ValidationError(errors)

  s3_link = upload.upload(id, uploader.get_max_resource_size())
  if s3_link:
    pkg_dict['resources'][n]['url_type'] = ''
    pkg_dict['resources'][n]['url'] = 'https://s3.amazonaws.com/' + s3_link
    _get_action('package_update')(context, pkg_dict)

  model.repo.commit()
  return _get_action('resource_show')(context, {'id': id})


resource_update.__doc__ = origin.resource_update.__doc__
예제 #2
0
        if p['id'] == id:
            break
    else:
        log.error('Could not find resource ' + id)
        raise NotFound(_('Resource was not found.'))

    upload = uploader.S3Upload(data_dict)

    pkg_dict['resources'][n] = data_dict

    try:
        context['defer_commit'] = True
        context['use_cache'] = False
        pkg_dict = _get_action('package_update')(context, pkg_dict)
        context.pop('defer_commit')
    except ValidationError, e:
        errors = e.error_dict['resources'][n]
        raise ValidationError(errors)

    s3_link = upload.upload(id, uploader.get_max_resource_size())
    if s3_link:
        pkg_dict['resources'][n]['url_type'] = ''
        pkg_dict['resources'][n]['url'] = 'https://s3.amazonaws.com/' + s3_link
        _get_action('package_update')(context, pkg_dict)

    model.repo.commit()
    return _get_action('resource_show')(context, {'id': id})


resource_update.__doc__ = origin.resource_update.__doc__
  pkg_dict['resources'].append(data_dict)

  try:
    context['defer_commit'] = True
    context['use_cache'] = False
    _get_action('package_update')(context, pkg_dict)
    context.pop('defer_commit')
  except ValidationError, e:
    errors = e.error_dict['resources'][-1]
    raise ValidationError(errors)

  ## Get out resource_id resource from model as it will not appear in
  ## package_show until after commit
  s3_link = upload.upload(context['package'].resources[-1].id,
                uploader.get_max_resource_size())

  if s3_link:
    pkg_dict['resources'][-1]['url_type'] = ''
    pkg_dict['resources'][-1]['url'] = 'https://s3.amazonaws.com/' + s3_link
    _get_action('package_update')(context, pkg_dict)

  model.repo.commit()

  ##  Run package show again to get out actual last_resource
  pkg_dict = _get_action('package_show')(context, {'id': package_id})
  resource = pkg_dict['resources'][-1]

  return resource

resource_create.__doc__ = origin.resource_create.__doc__