Pārlūkot izejas kodu

fixes to api

version-14
Rushabh Mehta pirms 11 gadiem
vecāks
revīzija
f41f219c33
4 mainītis faili ar 16 papildinājumiem un 13 dzēšanām
  1. +7
    -7
      webnotes/api.py
  2. +5
    -3
      webnotes/model/bean.py
  3. +3
    -2
      webnotes/utils/response.py
  4. +1
    -1
      webnotes/widgets/reportview.py

+ 7
- 7
webnotes/api.py Parādīt failu

@@ -48,14 +48,12 @@ def handle():
if webnotes.local.request.method=="GET":
if not bean.has_permission("read"):
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 not bean.has_permission("write"):
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()

else:
@@ -86,11 +84,13 @@ def handle():
doctype, **webnotes.local.form_dict)})
else:
raise Exception("Bad API")
raise webnotes.DoesNotExistError
else:
raise Exception("Bad API")
raise webnotes.DoesNotExistError
except webnotes.DoesNotExistError, e:
report_error(404)
except Exception, e:
report_error(500)


+ 5
- 3
webnotes/model/bean.py Parādīt failu

@@ -229,9 +229,11 @@ class Bean:
out.update(new_response)
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):
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
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))

self.set_doclist(self.controller.doclist)
return webnotes.local.response
def get_attr(self, method):


+ 3
- 2
webnotes/utils/response.py Parādīt failu

@@ -2,7 +2,7 @@
# MIT License. See license.txt

from __future__ import unicode_literals
import json, inspect
import json
import datetime
import gzip, cStringIO
import webnotes
@@ -12,7 +12,8 @@ import webnotes.model.utils
from werkzeug.local import LocalProxy

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
if webnotes.request_method == "POST":
webnotes.conn.rollback()


+ 1
- 1
webnotes/widgets/reportview.py Parādīt failu

@@ -27,7 +27,7 @@ def get_form_params():
return data
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):
"""


Notiek ielāde…
Atcelt
Saglabāt