Commit 2f487f34 authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

Avoid vanishing of error message during concepts import w/ pyramid

It seems that on form validation error when using the pyramid front-end, the
form values are stored by pyramid in the session cookie. If we don't pop
'stream' first, this silently fails because StringIO are not pickleable (and
_set_cookie fails silently), leading to a redirect to the original form without
any information.

Closes #17106505
parent 434e46b4368f
......@@ -350,7 +350,14 @@ class ImportSchemeConceptsView(ImportSchemeConceptsMixIn, EntityView):
raise ValidationError(None, {'stream': self._cw.__("required field")})
kwargs = {field.name: posted[field.name] for field in form._fields_}
kwargs['delimiter'] = CSV_DELIMITERS[kwargs['delimiter']]
_handle_concepts_import(self._cw, entity, kwargs.pop('format'), **kwargs)
try:
_handle_concepts_import(self._cw, entity, kwargs.pop('format'), **kwargs)
except:
# for unclear reason we have to pop stream from form data, else
# it's stored in session's data while it's not pickleable,
# leading to silent error in set_cookie with pyramid.
self._cw.form.pop('stream')
raise
raise Redirect(entity.absolute_url(__message=self._cw._('Import completed')))
else:
form.render(w=self.w)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment