summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLV-426 <lv-426@taproot.org.il>2015-03-30 18:45:31 +0300
committerLV-426 <lv-426@taproot.org.il>2015-04-01 22:25:53 +0300
commit9b0d7ff1e52cfbfc69d0e27dc898cbeea4573488 (patch)
treee48417d52a166b651dee45682abab6c34c1c0641 /src
parenta869f46fb9a2e53b15f83422628d9c0795d2a07f (diff)
diff_commit__topo, diff_commit__attr: use @common_rest_req_exception_handler
Diffstat (limited to 'src')
-rw-r--r--src/server/rz_api_rest.py49
1 files changed, 14 insertions, 35 deletions
diff --git a/src/server/rz_api_rest.py b/src/server/rz_api_rest.py
index 4c024fc1..e1788586 100644
--- a/src/server/rz_api_rest.py
+++ b/src/server/rz_api_rest.py
@@ -68,6 +68,7 @@ class Req_Context():
+@common_rest_req_exception_handler
def diff_commit__topo():
"""
REST API wrapper around diff_commit__topo():
@@ -82,22 +83,14 @@ def diff_commit__topo():
sanitize_input__topo_diff(topo_diff)
return rzdoc_name, topo_diff
- try:
- rzdoc_name, topo_diff = sanitize_input(request)
- except Exception as e:
- return common_resp_handle(error='malformed input')
+ rzdoc_name, topo_diff = sanitize_input(request)
- rzdoc_id = map_rzdoc_name_to_rzdoc_id(rzdoc_name)
- ctx = __context__common(rzdoc_id=rzdoc_id)
- try:
- kernel = flask.current_app.kernel
- _, commit_ret = kernel.diff_commit__topo(topo_diff, ctx)
- return common_resp_handle(data=commit_ret)
- except Exception as e:
- log.error(e.message)
- log.error(traceback.print_exc())
- return common_resp_handle(error=e)
+ 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)
+@common_rest_req_exception_handler
def diff_commit__attr():
"""
commit a graph attribute diff
@@ -108,29 +101,15 @@ def diff_commit__attr():
attr_diff = Attr_Diff.from_json_dict(attr_diff_dict)
sanitize_input__attr_diff(attr_diff)
-
- return rzdoc_name, attr_diff;
- def on_error(e):
- # handle DB ERRORS, eg. name attr change error
- return common_resp_handle(error='error occurred')
-
- try:
- rzdoc_name, attr_diff = sanitize_input(request)
- validate_obj__attr_diff(attr_diff)
- except Exception as e:
- return common_resp_handle(error='malformed input')
+ return rzdoc_name, attr_diff;
- rzdoc_id = map_rzdoc_name_to_rzdoc_id(rzdoc_name)
- ctx = __context__common(rzdoc_id=rzdoc_id)
- try:
- kernel = flask.current_app.kernel
- _, commit_ret = kernel.diff_commit__attr(attr_diff, ctx)
- return common_resp_handle(data=commit_ret)
- except Exception as e:
- log.error(e.message)
- log.error(traceback.print_exc())
- return common_resp_handle(error=e)
+ 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)
def diff_commit__vis():
pass