Exemple #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
Exemple #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')
Exemple #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')
Exemple #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))
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #19
0
def index(owner):
    """ List all the resources of a particular user. """
    result = logic.resource.list_by_owner(owner)
    return jsonify(list(result))
Exemple #20
0
def index(owner):
    """ List all the datasets of a particular user. """
    result = logic.dataset.list_by_owner(owner)
    return jsonify(list(result))
Exemple #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)
Exemple #22
0
def apiroot():
    return jsonify({
        'api': 'ok',
        'version': 1,
        'site_id': app.config.get('SITE_ID', 'datahub.local')
    })
Exemple #23
0
def index(owner):
    """ List all the resources of a particular user. """
    result = logic.resource.list_by_owner(owner)
    return jsonify(list(result))
Exemple #24
0
def apiroot():
    return jsonify({'api': 'ok', 
                    'version': 1, 
                    'site_id': app.config.get('SITE_ID', 'datahub.local')
                    })