@@ -48,14 +48,12 @@ def handle(): | |||||
if webnotes.local.request.method=="GET": | if webnotes.local.request.method=="GET": | ||||
if not bean.has_permission("read"): | if not bean.has_permission("read"): | ||||
webnotes.throw("No Permission", webnotes.PermissionError) | webnotes.throw("No Permission", webnotes.PermissionError) | ||||
webnotes.local.response.update({"data": bean.run_method(webnotes.local.form_dict.run_method, | |||||
**webnotes.local.form_dict)}) | |||||
bean.run_method(webnotes.local.form_dict.run_method, **webnotes.local.form_dict) | |||||
if webnotes.local.request.method=="POST": | if webnotes.local.request.method=="POST": | ||||
if not bean.has_permission("write"): | if not bean.has_permission("write"): | ||||
webnotes.throw("No Permission", webnotes.PermissionError) | webnotes.throw("No Permission", webnotes.PermissionError) | ||||
webnotes.local.response.update({"data":bean.run_method(webnotes.local.form_dict.run_method, | |||||
**webnotes.local.form_dict)}) | |||||
bean.run_method(webnotes.local.form_dict.run_method, **webnotes.local.form_dict) | |||||
webnotes.conn.commit() | webnotes.conn.commit() | ||||
else: | else: | ||||
@@ -86,11 +84,13 @@ def handle(): | |||||
doctype, **webnotes.local.form_dict)}) | doctype, **webnotes.local.form_dict)}) | ||||
else: | else: | ||||
raise Exception("Bad API") | |||||
raise webnotes.DoesNotExistError | |||||
else: | else: | ||||
raise Exception("Bad API") | |||||
raise webnotes.DoesNotExistError | |||||
except webnotes.DoesNotExistError, e: | |||||
report_error(404) | |||||
except Exception, e: | except Exception, e: | ||||
report_error(500) | report_error(500) | ||||
@@ -229,9 +229,11 @@ class Bean: | |||||
out.update(new_response) | out.update(new_response) | ||||
if hasattr(self.controller, method): | if hasattr(self.controller, method): | ||||
add_to_response(webnotes.local.response, webnotes.call(getattr(self.controller, method), *args, **kwargs)) | |||||
add_to_response(webnotes.local.response, | |||||
webnotes.call(getattr(self.controller, method), *args, **kwargs)) | |||||
if hasattr(self.controller, 'custom_' + method): | if hasattr(self.controller, 'custom_' + method): | ||||
add_to_response(webnotes.local.response, webnotes.call(getattr(self.controller, 'custom_' + method), *args, **kwargs)) | |||||
add_to_response(webnotes.local.response, | |||||
webnotes.call(getattr(self.controller, 'custom_' + method), *args, **kwargs)) | |||||
args = [self, method] + args | args = [self, method] + args | ||||
for handler in webnotes.get_hooks("bean_event:" + self.doc.doctype + ":" + method) \ | for handler in webnotes.get_hooks("bean_event:" + self.doc.doctype + ":" + method) \ | ||||
@@ -239,7 +241,7 @@ class Bean: | |||||
add_to_response(webnotes.local.response, webnotes.call(webnotes.get_attr(handler), *args, **kwargs)) | add_to_response(webnotes.local.response, webnotes.call(webnotes.get_attr(handler), *args, **kwargs)) | ||||
self.set_doclist(self.controller.doclist) | self.set_doclist(self.controller.doclist) | ||||
return webnotes.local.response | return webnotes.local.response | ||||
def get_attr(self, method): | def get_attr(self, method): | ||||
@@ -2,7 +2,7 @@ | |||||
# MIT License. See license.txt | # MIT License. See license.txt | ||||
from __future__ import unicode_literals | from __future__ import unicode_literals | ||||
import json, inspect | |||||
import json | |||||
import datetime | import datetime | ||||
import gzip, cStringIO | import gzip, cStringIO | ||||
import webnotes | import webnotes | ||||
@@ -12,7 +12,8 @@ import webnotes.model.utils | |||||
from werkzeug.local import LocalProxy | from werkzeug.local import LocalProxy | ||||
def report_error(status_code): | def report_error(status_code): | ||||
webnotes.errprint(webnotes.utils.get_traceback()) | |||||
if status_code!=404: | |||||
webnotes.errprint(webnotes.utils.get_traceback()) | |||||
webnotes._response.status_code = status_code | webnotes._response.status_code = status_code | ||||
if webnotes.request_method == "POST": | if webnotes.request_method == "POST": | ||||
webnotes.conn.rollback() | webnotes.conn.rollback() | ||||
@@ -27,7 +27,7 @@ def get_form_params(): | |||||
return data | return data | ||||
def execute(doctype, query=None, filters=None, fields=None, docstatus=None, | def execute(doctype, query=None, filters=None, fields=None, docstatus=None, | ||||
group_by=None, order_by=None, limit_start=0, limit_page_length=None, | |||||
group_by=None, order_by=None, limit_start=0, limit_page_length=20, | |||||
as_list=False, with_childnames=False, debug=False): | as_list=False, with_childnames=False, debug=False): | ||||
""" | """ | ||||