Only execute pathfields expressions and functions if they are called with an Item argument. Otherwise, return an empty string.

This commit is contained in:
Tai Lee 2013-05-25 12:28:52 +10:00
parent 3f4e194c41
commit e3fa403ad2

View file

@ -80,6 +80,8 @@ def compile_inline(python_code):
if is_expr:
# For expressions, just evaluate and return the result.
def _expr_func(obj):
if not isinstance(obj, Item):
return u''
values = _record(obj)
try:
return eval(code, values)
@ -90,6 +92,8 @@ def compile_inline(python_code):
# For function bodies, invoke the function with values as global
# variables.
def _func_func(obj):
if not isinstance(obj, Item):
return u''
func.__globals__.update(_record(obj))
try:
return func()