How to use the eve.methods.put.put_internal function in Eve

To help you get started, we’ve selected a few Eve examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github armadillica / pillar / old-src / manage.py View on Github external
def _update_project(project_uuid, project):
    """Updates a project in the database, or SystemExit()s.

    :param project_uuid: UUID of the project
    :type: str
    :param project: the project data, should be the entire project document
    :type: dict
    :return: the project
    :rtype: dict
    """

    from pillar.api.utils import remove_private_keys

    project_id = ObjectId(project_uuid)
    project = remove_private_keys(project)
    result, _, _, _ = put_internal('projects', project, _id=project_id)

    if result['_status'] != 'OK':
        log.error("Can't update project %s, issues: %s", project_uuid, result['_issues'])
        raise SystemExit()
github armadillica / flamenco / flamenco / server-eve / manage.py View on Github external
def _update_project(project_uuid, project):
    """Updates a project in the database, or SystemExit()s.

    :param project_uuid: UUID of the project
    :type: str
    :param project: the project data, should be the entire project document
    :type: dict
    :return: the project
    :rtype: dict
    """

    from application.utils import remove_private_keys

    project_id = ObjectId(project_uuid)
    project = remove_private_keys(project)
    result, _, _, _ = put_internal('projects', project, _id=project_id)

    if result['_status'] != 'OK':
        log.error("Can't update project %s, issues: %s", project_uuid, result['_issues'])
        raise SystemExit()
github armadillica / dillo / dillo / setup.py View on Github external
def _update_project(project):
    """Updates a project in the database, or SystemExit()s.

    :param project: the project data, should be the entire project document
    :type: dict
    :return: the project
    :rtype: dict
    """

    from pillar.api.utils import remove_private_keys

    project_id = ObjectId(project['_id'])
    project = remove_private_keys(project)
    result, _, _, status_code = put_internal('projects', project, _id=project_id)

    if status_code != 200:
        raise RuntimeError("Can't update project %s, issues: %s", project_id, result)
github armadillica / flamenco / flamenco / server-eve / manage.py View on Github external
def put_item(collection, item):
    item_id = item['_id']
    internal_fields = ['_id', '_etag', '_updated', '_created']
    for field in internal_fields:
        item.pop(field, None)
    # print item
    # print type(item_id)
    p = put_internal(collection, item, **{'_id': item_id})
    if p[0]['_status'] == 'ERR':
        print(p)
        print(item)
github armadillica / pillar / old-src / manage.py View on Github external
def put_item(collection, item):
    item_id = item['_id']
    internal_fields = ['_id', '_etag', '_updated', '_created']
    for field in internal_fields:
        item.pop(field, None)
    # print item
    # print type(item_id)
    p = put_internal(collection, item, **{'_id': item_id})
    if p[0]['_status'] == 'ERR':
        print(p)
        print(item)
github armadillica / flamenco / flamenco / server-eve / application / modules / blender_id.py View on Github external
"""Inserts/updates the user in MongoDB.

    Retries a few times when there are uniqueness issues in the username.

    :returns: the user's database ID and the status of the PUT/POST.
        The status is 201 on insert, and 200 on update.
    :type: (ObjectId, int)
    """

    r = {}
    for retry in range(5):
        if '_id' in db_user:
            # Update the existing user
            attempted_eve_method = 'PUT'
            db_id = db_user['_id']
            r, _, _, status = put_internal('users', remove_private_keys(db_user),
                                           _id=db_id)
            if status == 422:
                log.error('Status %i trying to PUT user %s with values %s, should not happen! %s',
                          status, db_id, remove_private_keys(db_user), r)
        else:
            # Create a new user, retry for non-unique usernames.
            attempted_eve_method = 'POST'
            r, _, _, status = post_internal('users', db_user)

            if status not in {200, 201}:
                log.error('Status %i trying to create user for BlenderID %s with values %s: %s',
                          status, blender_id_user_id, db_user, r)
                raise wz_exceptions.InternalServerError()

            db_id = r['_id']
            db_user.update(r)  # update with database/eve-generated fields.
github armadillica / flamenco / packages / flamenco / flamenco / shots / __init__.py View on Github external
else:
        # Remaining operations are for marking as 'in use' or 'not in use'.
        if node.get('_deleted', False) and op == u'unlink':
            # We won't undelete a node in response to an unlink request.
            return pillar.api.utils.jsonify({'_deleted': True,
                                             '_etag': node['_etag'],
                                             '_id': node['_id']})

        used_in_edit = {
            u'unlink': False,
            u'relink': True,
        }[op]
        node['properties']['used_in_edit'] = used_in_edit

    node = pillar.api.utils.remove_private_keys(node)
    r, _, _, status = put_internal('nodes', node, _id=node_id)
    return pillar.api.utils.jsonify(r, status=status)
github armadillica / flamenco / flamenco / server-eve / application / modules / file_storage.py View on Github external
src_file['status'] = 'complete'
    else:
        log.debug('process_file(%s): marking file status as "processing"', file_id)
        src_file['status'] = 'processing'
        update_file_doc(file_id, status='processing')

        try:
            processor(gcs, file_id, local_file, src_file)
        except Exception:
            log.warning('process_file(%s): error when processing file, resetting status to '
                        '"queued_for_processing"', file_id, exc_info=True)
            update_file_doc(file_id, status='queued_for_processing')
            return

    # Update the original file with additional info, e.g. image resolution
    r, _, _, status = put_internal('files', src_file, _id=file_id)
    if status not in (200, 201):
        log.warning('process_file(%s): status %i when saving processed file info to MongoDB: %s',
                    file_id, status, r)