diff --git a/tests/template-with-image-django-syntax.odt b/tests/template-with-image-django-syntax.odt new file mode 100644 index 000000000..db262a55e Binary files /dev/null and b/tests/template-with-image-django-syntax.odt differ diff --git a/tests/test_workflows.py b/tests/test_workflows.py index 6d4d2e50e..b5499bff6 100644 --- a/tests/test_workflows.py +++ b/tests/test_workflows.py @@ -3757,7 +3757,10 @@ def test_transform_to_pdf(): assert outstream.read(10).startswith(b'%PDF-') -def test_export_to_model_image(pub): +@pytest.mark.parametrize( + 'template_name', ['template-with-image.odt', 'template-with-image-django-syntax.odt'] +) +def test_export_to_model_image(pub, template_name): formdef = FormDef() formdef.name = 'baz' formdef.fields = [ @@ -3779,7 +3782,7 @@ def test_export_to_model_image(pub): item = ExportToModel() item.convert_to_pdf = False item.method = 'non-interactive' - template_filename = os.path.join(os.path.dirname(__file__), 'template-with-image.odt') + template_filename = os.path.join(os.path.dirname(__file__), template_name) with open(template_filename, 'rb') as fd: template = fd.read() upload = QuixoteUpload('/foo/template.odt', content_type='application/octet-stream') diff --git a/wcs/wf/export_to_model.py b/wcs/wf/export_to_model.py index f771d7f92..cfb27d270 100644 --- a/wcs/wf/export_to_model.py +++ b/wcs/wf/export_to_model.py @@ -587,17 +587,18 @@ class ExportToModel(WorkflowStatusItem): if node.tag == DRAW_FRAME: name = node.attrib.get(DRAW_NAME) - if not self.get_expression(name)['type'] == 'python': - continue # variable image - try: - variable_image = self.compute(name) - except Exception: - continue - if not hasattr(variable_image, 'get_content'): + pub = get_publisher() + with pub.complex_data(): + try: + variable_image = self.compute(name, allow_complex=True) + except Exception: + continue + complex_variable_image = get_publisher().get_cached_complex_data(variable_image) + if not hasattr(complex_variable_image, 'get_content'): continue image = [x for x in node if x.tag == DRAW_IMAGE][0] - new_images[image.attrib.get(XLINK_HREF)] = variable_image + new_images[image.attrib.get(XLINK_HREF)] = complex_variable_image for attr in ('text', 'tail'): if not getattr(node, attr):