示例#1
0
def setarc(_resp, arc, origin_id, destination_id):
    arc_cls = all_arcs.get(arc)
    arc_count = Arc.query(Arc.origin == to_node_key(origin_id), Arc.destination == to_node_key(destination_id)).count()
    if arc_count > 0:
        _resp.write("Arc already exists")
    else:
        arc_cls(origin=to_node_key(origin_id), destination=to_node_key(destination_id)).put()
        _resp.write("Arc Created")
示例#2
0
def find(_resp, id, arc=None):
    if arc:
        arc_cls = all_arcs.get(arc)
        destinations = DestinationsSearch(arc_cls, id).execute().result
        destination_dct_list = [__extract_dct(d) for d in destinations]
        js = json.dumps(destination_dct_list)
        _resp.write(js)
    else:
        node = NodeSearch(id).execute().result
        js = json.dumps(__extract_dct(node))
        _resp.write(js)