示例#1
0
def handle_exceptions(exc):
    """ Re-format exceptions to JSON if accept requires that. """
    format = response_format(app, request)
    if format == 'json':
        body = {'status': exc.code,
                'name': exc.name,
                'description': exc.get_description(request.environ)}
        return jsonify(body, status=exc.code,
                       headers=exc.get_headers(request.environ))
    return exc
示例#2
0
def handle_invalid(exc):
    format = response_format(app, request)
    if format == 'json':
        body = {'status': 400,
                'name': 'Invalid Data',
                'description': unicode(exc),
                'errors': exc.unpack_errors()}
        return jsonify(body, status=400)
    return Response(repr(exc.unpack_errors()), status=400, 
                    mimetype='text/plain')
示例#3
0
def handle_invalid(exc):
    format = response_format(app, request)
    if format == 'json':
        body = {
            'status': 400,
            'name': 'Invalid Data',
            'description': unicode(exc),
            'errors': exc.unpack_errors()
        }
        return jsonify(body, status=400)
    return Response(repr(exc.unpack_errors()),
                    status=400,
                    mimetype='text/plain')
示例#4
0
def handle_exceptions(exc):
    """ Re-format exceptions to JSON if accept requires that. """
    format = response_format(app, request)
    if format == 'json':
        body = {
            'status': exc.code,
            'name': exc.name,
            'description': exc.get_description(request.environ)
        }
        return jsonify(body,
                       status=exc.code,
                       headers=exc.get_headers(request.environ))
    return exc
def index(owner):
    """ List all the datasets of a particular user. """
    result = logic.dataset.list_by_owner(owner)
    return jsonify(list(result))
示例#6
0
def update(owner, resource):
    """ Update the data of the resource. """
    data = request_content(request)
    resource = logic.resource.update(owner, resource, data)
    return jsonify(resource)
示例#7
0
def get(owner, resource):
    """ Get a JSON representation of the resource. """
    resource = logic.resource.find(owner, resource)
    return jsonify(resource)
示例#8
0
def stream(type, id):
    """ Get the latest events on the given event stream. """
    events = logic.event.latest_by_stream(type, id)
    events = Pager(events, '.stream', request.args, limit=50,
                   type=type, id=id)
    return jsonify(events)
示例#9
0
def get(owner, resource):
    """ Get a JSON representation of the resource. """
    resource = logic.resource.find(owner, resource)
    return jsonify(resource)
示例#10
0
def update(owner, dataset):
    """ Update the data of the dataset. """
    data = request_content(request)
    dataset = logic.dataset.update(owner, dataset, data)
    return jsonify(dataset)
示例#11
0
def resources_get(owner, dataset):
    """ Get a JSON representation of the resources in this dataset. """
    resources = logic.dataset.list_resources(owner, dataset)
    return jsonify(resources)
示例#12
0
def get(owner, dataset):
    """ Get a JSON representation of the dataset. """
    dataset = logic.dataset.find(owner, dataset)
    return jsonify(dataset)
示例#13
0
def get(account):
    """ Get a JSON representation of the account. """
    account = logic.account.find(account)
    return jsonify(account)
示例#14
0
def update(account):
    """ Update the data of the account profile. """
    data = request_content(request)
    account = logic.account.update(account, data)
    return jsonify(account)
示例#15
0
def get(event):
    """ Get a JSON representation of the event. """
    event = logic.event.find(event)
    return jsonify(event)
示例#16
0
def get(owner, dataset):
    """ Get a JSON representation of the dataset. """
    dataset = logic.dataset.find(owner, dataset)
    return jsonify(dataset)
示例#17
0
def resources_get(owner, dataset):
    """ Get a JSON representation of the resources in this dataset. """
    resources = logic.dataset.list_resources(owner, dataset)
    return jsonify(resources)
示例#18
0
def update(owner, dataset):
    """ Update the data of the dataset. """
    data = request_content(request)
    dataset = logic.dataset.update(owner, dataset, data)
    return jsonify(dataset)
示例#19
0
def index(owner):
    """ List all the resources of a particular user. """
    result = logic.resource.list_by_owner(owner)
    return jsonify(list(result))
示例#20
0
def index(owner):
    """ List all the datasets of a particular user. """
    result = logic.dataset.list_by_owner(owner)
    return jsonify(list(result))
示例#21
0
def update(owner, resource):
    """ Update the data of the resource. """
    data = request_content(request)
    resource = logic.resource.update(owner, resource, data)
    return jsonify(resource)
示例#22
0
def apiroot():
    return jsonify({
        'api': 'ok',
        'version': 1,
        'site_id': app.config.get('SITE_ID', 'datahub.local')
    })
示例#23
0
def index(owner):
    """ List all the resources of a particular user. """
    result = logic.resource.list_by_owner(owner)
    return jsonify(list(result))
示例#24
0
def apiroot():
    return jsonify({'api': 'ok', 
                    'version': 1, 
                    'site_id': app.config.get('SITE_ID', 'datahub.local')
                    })