From 12f193231d3c07ba208d01d673fb0ac0e8eaeab4 Mon Sep 17 00:00:00 2001 From: Kevin Shenk Date: Wed, 27 Mar 2024 05:56:28 -0400 Subject: [PATCH] refactor: enable website utils in safe_exec (#25365) Frappe Builder uses safe_exec to fetch dynamic data, and there are a few functions in website utilities which would be nice to have on that end, get_html_content_based_on_type especially. I added a few others which seemed useful and safe as well. --- frappe/utils/safe_exec.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/frappe/utils/safe_exec.py b/frappe/utils/safe_exec.py index 1401ffcea6..ad1edad943 100644 --- a/frappe/utils/safe_exec.py +++ b/frappe/utils/safe_exec.py @@ -262,6 +262,13 @@ def get_safe_globals(): before_rollback=frappe.db.before_rollback, add_index=frappe.db.add_index, ), + website=NamespaceDict( + abs_url=frappe.website.utils.abs_url, + extract_title=frappe.website.utils.extract_title, + get_boot_data=frappe.website.utils.get_boot_data, + get_home_page=frappe.website.utils.get_home_page, + get_html_content_based_on_type=frappe.website.utils.get_html_content_based_on_type, + ), lang=getattr(frappe.local, "lang", "en"), ), FrappeClient=FrappeClient,