changeset 31:83bca7dc9bfe

Return error response when a template couldn't be rendered
author Björn Ricks <bjoern.ricks@intevation.de>
date Thu, 16 Oct 2014 11:35:19 +0200
parents 9d65de2ebe22
children e6f2f1481de2
files odfcast/convert.py
diffstat 1 files changed, 8 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/odfcast/convert.py	Thu Oct 16 10:34:43 2014 +0200
+++ b/odfcast/convert.py	Thu Oct 16 11:35:19 2014 +0200
@@ -56,11 +56,14 @@
         outfile = self.save_form_file(ffile)
 
         if datadict:
-            tfile = tempfile.NamedTemporaryFile()
-            t = Template(outfile, tfile)
-            t.render(datadict)
-            outfile.close()
-            outfile = tfile
+            try:
+                tfile = tempfile.NamedTemporaryFile()
+                t = Template(outfile, tfile)
+                t.render(datadict)
+                outfile.close()
+                outfile = tfile
+            except:
+                return "Template error", 500
 
         if format != "odt":
             try:
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)