コード例 #1
0
ファイル: rz_api_rest.py プロジェクト: shlomif/rhizi
def __load_node_set_by_id_attr_common(rzdoc_name, id_set):
    """
    @param f_k: optional attribute filter key
    @param f_vset: possible key values to match against
    """
    ctx = __context__common(rzdoc_name)
    kernel = flask.current_app.kernel
    _, commit_ret = kernel.load_node_set_by_id_attr(id_set, ctx)
    return common_resp_handle__success(data=commit_ret)
コード例 #2
0
ファイル: rz_api_rest.py プロジェクト: yuvadm/rhizi
def __load_node_set_by_id_attr_common(rzdoc_name, id_set):
    """
    @param f_k: optional attribute filter key
    @param f_vset: possible key values to match against
    """
    ctx = __context__common(rzdoc_name)
    kernel = flask.current_app.kernel
    _, commit_ret = kernel.load_node_set_by_id_attr(id_set, ctx)
    return common_resp_handle__success(data=commit_ret)
コード例 #3
0
ファイル: rz_api_rest.py プロジェクト: shlomif/rhizi
def rzdoc_clone():

    def sanitize_input(req):
        rzdoc_name = req.get_json().get('rzdoc_name')
        return rzdoc_name

    rzdoc_name = sanitize_input(request)
    if None == rzdoc_name:  # load welcome doc by default
        rzdoc_name = current_app.rz_config.rzdoc__mainpage_name

    kernel = flask.current_app.kernel
    ctx = __context__common(rzdoc_name)
    topo_diff = kernel.rzdoc__clone(ctx.rzdoc, ctx)
    topo_diff_json = topo_diff.to_json_dict()  # serialize Topo_Diff before including in response
    commit_log = kernel.rzdoc__commit_log(ctx.rzdoc, limit=10)
    return common_resp_handle__success(data=[topo_diff_json, commit_log])
コード例 #4
0
ファイル: rz_api_rest.py プロジェクト: yuvadm/rhizi
def rzdoc_clone():
    def sanitize_input(req):
        rzdoc_name = req.get_json().get('rzdoc_name')
        return rzdoc_name

    rzdoc_name = sanitize_input(request)
    if None == rzdoc_name:  # load welcome doc by default
        rzdoc_name = current_app.rz_config.rzdoc__mainpage_name

    kernel = flask.current_app.kernel
    ctx = __context__common(rzdoc_name)
    topo_diff = kernel.rzdoc__clone(ctx.rzdoc, ctx)
    topo_diff_json = topo_diff.to_json_dict(
    )  # serialize Topo_Diff before including in response
    commit_log = kernel.rzdoc__commit_log(ctx.rzdoc, limit=10)
    return common_resp_handle__success(data=[topo_diff_json, commit_log])
コード例 #5
0
ファイル: rz_api_rest.py プロジェクト: shlomif/rhizi
def rzdoc__search():

    def sanitize_input(req):
        search_query = req.get_json().get('search_query')

        if search_query is None or \
           len(search_query) > current_app.rz_config.rzdoc__name__max_length:
            raise Exception('malformed rzdoc search query')

        return search_query

    search_query = sanitize_input(request)
    kernel = flask.current_app.kernel
    ctx = __context__common(rzdoc_name=None)  # avoid rzdoc cache lookup exception
    rzdoc_set = kernel.rzdoc__search(search_query, ctx)
    ret = [rzdoc_dict['name'] for rzdoc_dict in rzdoc_set]
    return common_resp_handle__success(data=ret)
コード例 #6
0
ファイル: rz_api_rest.py プロジェクト: yuvadm/rhizi
def rzdoc__search():
    def sanitize_input(req):
        search_query = req.get_json().get('search_query')

        if search_query is None or \
           len(search_query) > current_app.rz_config.rzdoc__name__max_length:
            raise Exception('malformed rzdoc search query')

        return search_query

    search_query = sanitize_input(request)
    kernel = flask.current_app.kernel
    ctx = __context__common(
        rzdoc_name=None)  # avoid rzdoc cache lookup exception
    rzdoc_set = kernel.rzdoc__search(search_query, ctx)
    ret = [rzdoc_dict['name'] for rzdoc_dict in rzdoc_set]
    return common_resp_handle__success(data=ret)
コード例 #7
0
ファイル: rz_api_rest.py プロジェクト: shlomif/rhizi
def diff_commit__attr():
    """
    commit a graph attribute diff
    """
    def sanitize_input(req):
        rzdoc_name = request.get_json().get('rzdoc_name')
        attr_diff_dict = request.get_json()['attr_diff']
        attr_diff = Attr_Diff.from_json_dict(attr_diff_dict)

        sanitize_input__attr_diff(attr_diff)

        return rzdoc_name, attr_diff;

    rzdoc_name, attr_diff = sanitize_input(request)
    validate_obj__attr_diff(attr_diff)
    ctx = __context__common(rzdoc_name)
    kernel = flask.current_app.kernel
    _, commit_ret = kernel.diff_commit__attr(attr_diff, ctx)
    return common_resp_handle__success(data=commit_ret)
コード例 #8
0
ファイル: rz_api_rest.py プロジェクト: yuvadm/rhizi
def diff_commit__attr():
    """
    commit a graph attribute diff
    """
    def sanitize_input(req):
        rzdoc_name = request.get_json().get('rzdoc_name')
        attr_diff_dict = request.get_json()['attr_diff']
        attr_diff = Attr_Diff.from_json_dict(attr_diff_dict)

        sanitize_input__attr_diff(attr_diff)

        return rzdoc_name, attr_diff

    rzdoc_name, attr_diff = sanitize_input(request)
    validate_obj__attr_diff(attr_diff)
    ctx = __context__common(rzdoc_name)
    kernel = flask.current_app.kernel
    _, commit_ret = kernel.diff_commit__attr(attr_diff, ctx)
    return common_resp_handle__success(data=commit_ret)
コード例 #9
0
ファイル: rz_api_rest.py プロジェクト: shlomif/rhizi
def diff_commit__topo():
    """
    REST API wrapper around diff_commit__topo():
       - extract topo_diff from request
       - handle success/error outcomes
    """
    def sanitize_input(req):
        rzdoc_name = request.get_json().get('rzdoc_name')
        topo_diff_dict = request.get_json()['topo_diff']
        topo_diff = Topo_Diff.from_json_dict(topo_diff_dict)

        sanitize_input__topo_diff(topo_diff)
        return rzdoc_name, topo_diff

    rzdoc_name, topo_diff = sanitize_input(request)
    if topo_diff.is_empty():
        return common_resp_handle__client_error()

    ctx = __context__common(rzdoc_name)
    kernel = flask.current_app.kernel
    _, commit_ret = kernel.diff_commit__topo(topo_diff, ctx)
    return common_resp_handle__success(data=commit_ret)
コード例 #10
0
ファイル: rz_api_rest.py プロジェクト: yuvadm/rhizi
def diff_commit__topo():
    """
    REST API wrapper around diff_commit__topo():
       - extract topo_diff from request
       - handle success/error outcomes
    """
    def sanitize_input(req):
        rzdoc_name = request.get_json().get('rzdoc_name')
        topo_diff_dict = request.get_json()['topo_diff']
        topo_diff = Topo_Diff.from_json_dict(topo_diff_dict)

        sanitize_input__topo_diff(topo_diff)
        return rzdoc_name, topo_diff

    rzdoc_name, topo_diff = sanitize_input(request)
    if topo_diff.is_empty():
        return common_resp_handle__client_error()

    ctx = __context__common(rzdoc_name)
    kernel = flask.current_app.kernel
    _, commit_ret = kernel.diff_commit__topo(topo_diff, ctx)
    return common_resp_handle__success(data=commit_ret)