misc: make allow_python=False parameter effective in get_expression() (#55977)
This commit is contained in:
parent
4df2721fac
commit
be60b83352
|
@ -2732,14 +2732,14 @@ class ComputedExpressionWidget(CompositeWidget):
|
|||
value = WorkflowStatusItem.get_expression(value)
|
||||
|
||||
value_placeholder = kwargs.pop('value_placeholder', None)
|
||||
allow_python = kwargs.pop('allow_python', True)
|
||||
self.allow_python = kwargs.pop('allow_python', True)
|
||||
CompositeWidget.__init__(self, name, value, **kwargs)
|
||||
|
||||
options = [
|
||||
('text', _('Text'), 'text'),
|
||||
('template', _('Template'), 'template'),
|
||||
]
|
||||
if allow_python:
|
||||
if self.allow_python:
|
||||
options.append(('python', _('Python Expression'), 'python'))
|
||||
|
||||
self.add(
|
||||
|
@ -2821,12 +2821,12 @@ class ComputedExpressionWidget(CompositeWidget):
|
|||
raise ValidationError('%s' % e)
|
||||
|
||||
@classmethod
|
||||
def validate(cls, expression):
|
||||
def validate(cls, expression, allow_python=True):
|
||||
if not expression:
|
||||
return
|
||||
from wcs.workflows import WorkflowStatusItem
|
||||
|
||||
expression = WorkflowStatusItem.get_expression(expression, allow_python=False)
|
||||
expression = WorkflowStatusItem.get_expression(expression, allow_python=allow_python)
|
||||
if expression['type'] == 'python':
|
||||
if '{{' in expression['value']:
|
||||
raise ValidationError(_('invalid usage, Python expression cannot contain {{'))
|
||||
|
@ -2849,7 +2849,7 @@ class ComputedExpressionWidget(CompositeWidget):
|
|||
self.value = value_content
|
||||
if self.value:
|
||||
try:
|
||||
self.validate(self.value)
|
||||
self.validate(self.value, allow_python=self.allow_python)
|
||||
except ValidationError as e:
|
||||
self.set_error(str(e))
|
||||
|
||||
|
|
|
@ -2172,7 +2172,7 @@ class WorkflowStatusItem(XmlSerialisable):
|
|||
if not var:
|
||||
expression_type = 'text'
|
||||
expression_value = ''
|
||||
elif var.startswith('='):
|
||||
elif var.startswith('=') and allow_python:
|
||||
expression_type = 'python'
|
||||
expression_value = var[1:]
|
||||
elif '{{' in var or '{%' in var or '[' in var:
|
||||
|
|
Loading…
Reference in New Issue