def object_relation_post(id): content = request.get_json() type_int = CPL.relation_str_to_type(str(content['type'])) if content['dest']: relation = cpl_object(id).relation_to( cpl_object(int(content['dest'])), type_int, cpl_bundle(int(content['bundle']))) else: relation = cpl_object(id).relation_from( cpl_object(int(content['src'])), type_int, cpl_bundle(int(content['bundle']))) return jsonify(id=relation.id)
def object_relation_post(id): content = request.get_json() type_int = CPL.relation_str_to_type(str(content['type'])) if content['dest']: relation = cpl_object(id).relation_to(cpl_object(int(content['dest'])), type_int, cpl_bundle(int(content['bundle']))) else: relation = cpl_object(id).relation_from(cpl_object(int(content['src'])), type_int, cpl_bundle(int(content['bundle']))) return jsonify(id=relation.id)
def json_post(): content = request.get_json() if content.get('anchor_objects'): anchors = [(cpl_object(int(a['id'])), str(a['name'])) for a in content['anchor_objects']] else: anchors = None bundle = connection.import_document_json(str(json.dumps(content['JSON'],ensure_ascii = False)), str(content['bundle_name']), anchors) return jsonify(id=bundle.id)
def json_post(): content = request.get_json() if content.get('anchor_objects'): anchors = [(cpl_object(int(a['id'])), str(a['name'])) for a in content['anchor_objects']] else: anchors = None bundle = connection.import_document_json( str(json.dumps(content['JSON'], ensure_ascii=False)), str(content['bundle_name']), anchors) return jsonify(id=bundle.id)
def object_descendants_get(id): relations = cpl_object(id).relations(CPL.D_DESCENDANTS) return jsonify([serialize_relation_info(info) for info in relations])
def object_ancestors_get(id): relations = cpl_object(id).relations() return jsonify(relations=[serialize_relation_info(info) for info in relations])
def object_property_post(id): content = request.get_json() cpl_object(id).add_property(str(content['prefix']), str(content['name']), str(content['value'])) return jsonify(success=True)
def object_property_get(id, prefix=None, property=None): properties = cpl_object(id).properties(prefix, property) return jsonify(properties= [serialize_property_tuple(prop) for prop in properties])
def object_get(id): info = cpl_object(id).info return jsonify(serialize_object_info(info))
def object_ancestors_get(id): relations = cpl_object(id).relations() return jsonify( relations=[serialize_relation_info(info) for info in relations])
def object_property_get(id, prefix=None, property=None): properties = cpl_object(id).properties(prefix, property) return jsonify( properties=[serialize_property_tuple(prop) for prop in properties])