|
|
@@ -10,13 +10,22 @@ import frappe.sessions |
|
|
|
import frappe.utils.file_manager |
|
|
|
import frappe.desk.form.run_method |
|
|
|
from frappe.utils.response import build_response |
|
|
|
from werkzeug.wrappers import Response |
|
|
|
|
|
|
|
def handle(): |
|
|
|
"""handle request""" |
|
|
|
cmd = frappe.local.form_dict.cmd |
|
|
|
|
|
|
|
if cmd!='login': |
|
|
|
execute_cmd(cmd) |
|
|
|
data = execute_cmd(cmd) |
|
|
|
|
|
|
|
if data: |
|
|
|
if isinstance(data, Response): |
|
|
|
# method returns a response object, pass it on |
|
|
|
return data |
|
|
|
|
|
|
|
# add the response to `message` label |
|
|
|
frappe.response['message'] = data |
|
|
|
|
|
|
|
return build_response("json") |
|
|
|
|
|
|
@@ -39,11 +48,8 @@ def execute_cmd(cmd, from_async=False): |
|
|
|
|
|
|
|
is_whitelisted(method) |
|
|
|
|
|
|
|
ret = frappe.call(method, **frappe.form_dict) |
|
|
|
return frappe.call(method, **frappe.form_dict) |
|
|
|
|
|
|
|
# returns with a message |
|
|
|
if ret: |
|
|
|
frappe.response['message'] = ret |
|
|
|
|
|
|
|
def is_whitelisted(method): |
|
|
|
# check if whitelisted |
|
|
|