I was hoping this list of RestrictedPython commands was out of date. Seems not.
I really don’t get it. I seem to able to effect some fairly drastic changes to the database through a Server Script, but writing to a log file, “Oh, NO! Much too insecure!”
I wrote a new Python function to perform my logging. For example:
def brian_print(message):
print(message)
This example above is very simple. You could definitely do more, such as writing the ‘message’ to a file or database.
Next, you must teach Frappe Framework that your function is safe to use with Server Scripts.
The related code is found in apps/frappe/frappe/utils/safe_exec.py, a function named get_safe_globals()
See screenshot below. I altered the out dictionary, adding a reference to my new “brian_print” function.