In the ExportToModel workflow item, better report errors during templating

This commit is contained in:
Benjamin Dauvergne 2011-06-21 20:07:41 +00:00
parent e1ffc483fb
commit 0d0c5122ea
1 changed files with 17 additions and 2 deletions

View File

@ -27,6 +27,7 @@ from qommon.form import *
from qommon import emails, get_cfg, get_logger
from quixote.directory import Directory
from quixote.html import htmltext
import quixote.errors
from wcs.roles import Role, logged_users_role, get_user_roles
from wcs.formdata import Evolution
@ -42,6 +43,11 @@ def lax_int(s):
return -1
class TemplatingError(quixote.errors.PublishError):
def __init__(self, title, description):
self.title = title
self.description = description
ADDITIONAL_VARIABLES = (
('url', _('URL of the form')),
('url_status', _('URL of the form status')),
@ -863,8 +869,17 @@ class ExportToModel(WorkflowStatusItem):
process = None
if self.model_file.base_filename.endswith('.rtf'):
process = rtf_process
return template_on_formdata(formdata, self.model_file.get_file().read(),
process=process)
try:
return template_on_formdata(formdata, self.model_file.get_file().read(),
process=process)
except ezt.UnknownReference, e:
url = formdata.get_url()
get_logger().error('error in template for export to model [%s], unknown reference %s' % (url, str(e)))
raise TemplatingError(_('Templating error'), _('Error in the template, reference %s is unknown') % str(e))
except ezt.EZTException, e:
url = formdata.get_url()
get_logger().error('error in template for export to model [%s], model could not be generated' % url)
raise TemplatingError(_('Templating error'), _('Unknown error in the template: %s') % str(e))
def get_parameters(self):
return ('label', 'model_file')