Merge pull request #16337 from alyf-de/dont-assign-variable-to-itself
refactor: don't assign variable to itself
This commit is contained in:
commit
dbff1de9ac
1 changed files with 7 additions and 10 deletions
17
frappe/handler.py
Executable file → Normal file
17
frappe/handler.py
Executable file → Normal file
|
|
@ -225,11 +225,10 @@ def ping():
|
|||
|
||||
def run_doc_method(method, docs=None, dt=None, dn=None, arg=None, args=None):
|
||||
"""run a whitelisted controller method"""
|
||||
import json
|
||||
import inspect
|
||||
from inspect import getfullargspec
|
||||
|
||||
if not args:
|
||||
args = arg or ""
|
||||
if not args and arg:
|
||||
args = arg
|
||||
|
||||
if dt: # not called from a doctype (from a page)
|
||||
if not dn:
|
||||
|
|
@ -237,9 +236,7 @@ def run_doc_method(method, docs=None, dt=None, dn=None, arg=None, args=None):
|
|||
doc = frappe.get_doc(dt, dn)
|
||||
|
||||
else:
|
||||
if isinstance(docs, str):
|
||||
docs = json.loads(docs)
|
||||
|
||||
docs = frappe.parse_json(docs)
|
||||
doc = frappe.get_doc(docs)
|
||||
doc._original_modified = doc.modified
|
||||
doc.check_if_latest()
|
||||
|
|
@ -248,16 +245,16 @@ def run_doc_method(method, docs=None, dt=None, dn=None, arg=None, args=None):
|
|||
throw_permission_error()
|
||||
|
||||
try:
|
||||
args = json.loads(args)
|
||||
args = frappe.parse_json(args)
|
||||
except ValueError:
|
||||
args = args
|
||||
pass
|
||||
|
||||
method_obj = getattr(doc, method)
|
||||
fn = getattr(method_obj, '__func__', method_obj)
|
||||
is_whitelisted(fn)
|
||||
is_valid_http_method(fn)
|
||||
|
||||
fnargs = inspect.getfullargspec(method_obj).args
|
||||
fnargs = getfullargspec(method_obj).args
|
||||
|
||||
if not fnargs or (len(fnargs)==1 and fnargs[0]=="self"):
|
||||
response = doc.run_method(method)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue