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.
This commit is contained in:
Kevin Shenk 2024-03-27 05:56:28 -04:00 committed by GitHub
parent b7bc5d3236
commit 12f193231d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -262,6 +262,13 @@ def get_safe_globals():
before_rollback=frappe.db.before_rollback, before_rollback=frappe.db.before_rollback,
add_index=frappe.db.add_index, 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"), lang=getattr(frappe.local, "lang", "en"),
), ),
FrappeClient=FrappeClient, FrappeClient=FrappeClient,