fix(server-script): add common python builtins
This commit is contained in:
parent
f6c38b6b6e
commit
7c8659388d
1 changed files with 30 additions and 1 deletions
|
|
@ -184,10 +184,39 @@ def get_safe_globals():
|
|||
# allow iterators and list comprehension
|
||||
out._getiter_ = iter
|
||||
out._iter_unpack_sequence_ = RestrictedPython.Guards.guarded_iter_unpack_sequence
|
||||
out.sorted = sorted
|
||||
|
||||
# add common python builtins
|
||||
out.update(get_python_builtins())
|
||||
|
||||
return out
|
||||
|
||||
def get_python_builtins():
|
||||
return {
|
||||
'abs': abs,
|
||||
'all': all,
|
||||
'any': any,
|
||||
'bool': bool,
|
||||
'delattr': delattr,
|
||||
'dict': dict,
|
||||
'enumerate': enumerate,
|
||||
'filter': filter,
|
||||
'getattr': getattr,
|
||||
'hasattr': hasattr,
|
||||
'isinstance': isinstance,
|
||||
'issubclass': issubclass,
|
||||
'list': list,
|
||||
'map': map,
|
||||
'max': max,
|
||||
'min': min,
|
||||
'range': range,
|
||||
'set': set,
|
||||
'setattr': setattr,
|
||||
'sorted': sorted,
|
||||
'sum': sum,
|
||||
'tuple': tuple,
|
||||
'type': type,
|
||||
}
|
||||
|
||||
def get_hooks(hook=None, default=None, app_name=None):
|
||||
hooks = frappe.get_hooks(hook=hook, default=default, app_name=app_name)
|
||||
return copy.deepcopy(hooks)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue