Can you please explain which scheduled event you want to running this function. You monkey patch is absolutely correct. We have also written lots of monkey patches for clients but all monkey patches are running correctly in local server even also on a frappe cloud server.
When a I save the doc the monkey patch functions is called => Ok.
Second one:
Scheduled Event
Hourly
Code: the same as above.
When the second one is executed than here is this error in Scheduled Job Log:
Traceback (most recent call last):
File “apps/frappe/frappe/core/doctype/scheduled_job_type/scheduled_job_type.py”, line 97, in execute
frappe.get_doc(“Server Script”, script_name).execute_scheduled_method()
File “apps/frappe/frappe/core/doctype/server_script/server_script.py”, line 117, in execute_scheduled_method
safe_exec(self.script)
File “apps/frappe/frappe/utils/safe_exec.py”, line 85, in safe_exec
exec(
File “”, line 22, in
File “apps/frappe/frappe/integrations/utils.py”, line 49, in make_delete_request
return make_request(“DELETE”, url, **kwargs)
TypeError: make_request() got an unexpected keyword argument ‘response_body’
Here I can find that the original path is used (apps/frappe/frappe/integrations/utils.py).
Maybe this is the issue of combinations: frappe cloud, server script and scheduled event.
hi all,
Currently i wrote one monkey patch to change the session expiry msg and heading.
Override the is_whitelisted function in the path: apps/frappe/frappe/__init__.py
monkey_patch.py:
import frappe
from frappe import _
def custom_is_whitelisted(method):
from frappe.utils import sanitize_html
is_guest = frappe.session["user"] == "Guest"
if method not in frappe.whitelisted or is_guest and method not in frappe.guest_methods:
summary = _("🚫 Your session has expired. Please log in again to continue.")
# detail = _("Function {0} is not whitelisted.").format(frappe.bold(f"{method.__module__}.{method.__name__}"))
# msg = f"<details><summary>{summary}</summary>{detail}</details>"
msg = summary # Use summary directly as message without any HTML tags
frappe.throw(msg, frappe.PermissionError, title=_("Session Expired"))
if is_guest and method not in frappe.xss_safe_methods:
# strictly sanitize form_dict
# escapes html characters like <> except for predefined tags like a, b, ul etc.
for key, value in frappe.form_dict.items():
if isinstance(value, str):
frappe.form_dict[key] = sanitize_html(value)
# Apply the monkey patch
frappe.is_whitelisted = custom_is_whitelisted
In my custom app __ init __.py: from .monkey_patch import custom_is_whitelisted
this patch is working correctly in the local but not in the frappe cloud server why??
please sugguest any other ways !