From f9e120c1040e577acc673422c97cc0a51fb8e8ca Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Sun, 3 Sep 2023 21:11:20 +0530 Subject: [PATCH] refactor: remove unnessary manual commits --- frappe/api/v1.py | 6 ------ frappe/api/v2.py | 10 +--------- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/frappe/api/v1.py b/frappe/api/v1.py index d6fa5a365c..44496c82f2 100644 --- a/frappe/api/v1.py +++ b/frappe/api/v1.py @@ -48,9 +48,6 @@ def create_doc(doctype: str): # set response data frappe.local.response.update({"data": doc.as_dict()}) - # commit for POST requests - frappe.db.commit() - def read_doc(doctype: str, name: str): # Backward compatiblity @@ -81,7 +78,6 @@ def update_doc(doctype: str, name: str): # check for child table doctype if doc.get("parenttype"): frappe.get_doc(doc.parenttype, doc.parent).save() - frappe.db.commit() def delete_doc(doctype: str, name: str): @@ -89,7 +85,6 @@ def delete_doc(doctype: str, name: str): frappe.delete_doc(doctype, name, ignore_missing=False) frappe.local.response.http_status_code = 202 frappe.local.response.message = "ok" - frappe.db.commit() def execute_doc_method(doctype: str, name: str, method: str | None = None): @@ -107,7 +102,6 @@ def execute_doc_method(doctype: str, name: str, method: str | None = None): frappe.throw(_("Not permitted"), frappe.PermissionError) frappe.local.response.update({"data": doc.run_method(method, **frappe.local.form_dict)}) - frappe.db.commit() def get_request_form_data(): diff --git a/frappe/api/v2.py b/frappe/api/v2.py index 782f6183c5..a36d422311 100644 --- a/frappe/api/v2.py +++ b/frappe/api/v2.py @@ -13,7 +13,7 @@ def handle_rpc_call(method: str, doctype: str | None = None): from frappe.modules.utils import load_doctype_module if doctype: - # Expand to cover actual method + # Expand to run actual method module = load_doctype_module(doctype) method = module.__name__ + "." + method @@ -61,9 +61,6 @@ def create_doc(doctype: str): # set response data frappe.local.response.update({"data": doc.as_dict()}) - # commit for POST requests - frappe.db.commit() - def read_doc(doctype: str, name: str): doc = frappe.get_doc(doctype, name) @@ -89,15 +86,11 @@ def update_doc(doctype: str, name: str): # check for child table doctype if doc.get("parenttype"): frappe.get_doc(doc.parenttype, doc.parent).save() - frappe.db.commit() def delete_doc(doctype: str, name: str): - # Not checking permissions here because it's checked in delete_doc frappe.delete_doc(doctype, name, ignore_missing=False) frappe.local.response.http_status_code = 202 - frappe.local.response.message = "ok" - frappe.db.commit() def execute_doc_method(doctype: str, name: str, method: str | None = None): @@ -115,7 +108,6 @@ def execute_doc_method(doctype: str, name: str, method: str | None = None): frappe.throw(_("Not permitted"), frappe.PermissionError) frappe.local.response.update({"data": doc.run_method(method, **frappe.local.form_dict)}) - frappe.db.commit() def get_request_form_data():