add uniform globals to eval() used in different places
This commit is contained in:
parent
8eed0b3214
commit
d1075fe2c5
|
@ -863,7 +863,7 @@ class PageField(Field):
|
|||
data = get_dict_with_varnames(formdef.fields, dict)
|
||||
|
||||
try:
|
||||
if eval(self.condition, data):
|
||||
if eval(self.condition, get_publisher().get_global_eval_dict(), data):
|
||||
return True
|
||||
except Exception, e:
|
||||
get_logger().warn('failed to evaluate condition "%s" (%r)' % (self.condition, e))
|
||||
|
|
|
@ -129,6 +129,10 @@ class QommonPublisher(Publisher):
|
|||
urllib.quote(req.environ.get('SCRIPT_NAME')))
|
||||
return 'http://%s/backoffice' % os.path.basename(self.app_dir)
|
||||
|
||||
def get_global_eval_dict(self):
|
||||
import datetime
|
||||
return {'datetime': datetime}
|
||||
|
||||
def format_publish_error(self, exc):
|
||||
get_response().filter = {}
|
||||
if isinstance(exc, errors.AccessError) and hasattr(exc, 'render'):
|
||||
|
|
|
@ -58,7 +58,7 @@ class JumpWorkflowStatusItem(WorkflowStatusJumpItem):
|
|||
if self.condition:
|
||||
variables = get_publisher().substitutions.get_context_variables()
|
||||
try:
|
||||
condition = eval(self.condition, variables)
|
||||
condition = eval(self.condition, get_publisher().get_global_eval_dict(), variables)
|
||||
except:
|
||||
get_publisher().notify_of_exception(sys.exc_info())
|
||||
condition = False
|
||||
|
|
|
@ -490,7 +490,7 @@ class WorkflowStatusItem:
|
|||
return var
|
||||
vars = get_publisher().substitutions.get_context_variables()
|
||||
try:
|
||||
return eval(var[1:], vars)
|
||||
return eval(var[1:], get_publisher().get_global_eval_dict(), vars)
|
||||
except:
|
||||
return var
|
||||
|
||||
|
|
Loading…
Reference in New Issue