Beispiel #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
Beispiel #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')
Beispiel #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')
Beispiel #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))
Beispiel #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)
Beispiel #7
0
def get(owner, resource):
    """ Get a JSON representation of the resource. """
    resource = logic.resource.find(owner, resource)
    return jsonify(resource)
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)
Beispiel #9
0
def get(owner, resource):
    """ Get a JSON representation of the resource. """
    resource = logic.resource.find(owner, resource)
    return jsonify(resource)
def update(owner, dataset):
    """ Update the data of the dataset. """
    data = request_content(request)
    dataset = logic.dataset.update(owner, dataset, data)
    return jsonify(dataset)
Beispiel #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)
Beispiel #12
0
def get(owner, dataset):
    """ Get a JSON representation of the dataset. """
    dataset = logic.dataset.find(owner, dataset)
    return jsonify(dataset)
def get(account):
    """ Get a JSON representation of the account. """
    account = logic.account.find(account)
    return jsonify(account)
def update(account):
    """ Update the data of the account profile. """
    data = request_content(request)
    account = logic.account.update(account, data)
    return jsonify(account)
def get(event):
    """ Get a JSON representation of the event. """
    event = logic.event.find(event)
    return jsonify(event)
def get(owner, dataset):
    """ Get a JSON representation of the dataset. """
    dataset = logic.dataset.find(owner, dataset)
    return jsonify(dataset)
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)
Beispiel #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)
Beispiel #19
0
def index(owner):
    """ List all the resources of a particular user. """
    result = logic.resource.list_by_owner(owner)
    return jsonify(list(result))
Beispiel #20
0
def index(owner):
    """ List all the datasets of a particular user. """
    result = logic.dataset.list_by_owner(owner)
    return jsonify(list(result))
Beispiel #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)
Beispiel #22
0
def apiroot():
    return jsonify({
        'api': 'ok',
        'version': 1,
        'site_id': app.config.get('SITE_ID', 'datahub.local')
    })
Beispiel #23
0
def index(owner):
    """ List all the resources of a particular user. """
    result = logic.resource.list_by_owner(owner)
    return jsonify(list(result))
Beispiel #24
0
def apiroot():
    return jsonify({'api': 'ok', 
                    'version': 1, 
                    'site_id': app.config.get('SITE_ID', 'datahub.local')
                    })