web/views/editcontroller.py
changeset 10730 874ac29b515d
parent 10669 155c29e0ed1c
child 10932 cb217b2b3463
--- a/web/views/editcontroller.py	Tue Sep 22 15:01:16 2015 +0200
+++ b/web/views/editcontroller.py	Tue Sep 22 15:24:58 2015 +0200
@@ -24,6 +24,8 @@
 
 from datetime import datetime
 
+from six import text_type
+
 from logilab.common.deprecation import deprecated
 from logilab.common.graph import ordered_nodes
 
@@ -197,7 +199,7 @@
             if '__linkto' in req.form and 'eid' in req.form:
                 self.execute_linkto()
             elif not ('__delete' in req.form or '__insert' in req.form):
-                raise ValidationError(None, {None: unicode(ex)})
+                raise ValidationError(None, {None: text_type(ex)})
         # all pending inlined relations to newly created entities have been
         # treated now (pop to ensure there are no attempt to add new ones)
         pending_inlined = req.data.pop('pending_inlined')
@@ -215,7 +217,7 @@
                 autoform.delete_relations(self._cw, todelete)
         self._cw.remove_pending_operations()
         if self.errors:
-            errors = dict((f.name, unicode(ex)) for f, ex in self.errors)
+            errors = dict((f.name, text_type(ex)) for f, ex in self.errors)
             raise ValidationError(valerror_eid(form.get('__maineid')), errors)
 
     def _insert_entity(self, etype, eid, rqlquery):
@@ -265,7 +267,7 @@
         for form_, field in req.data['pending_inlined'].pop(entity.eid, ()):
             rqlquery.set_inlined(field.name, form_.edited_entity.eid)
         if self.errors:
-            errors = dict((f.role_name(), unicode(ex)) for f, ex in self.errors)
+            errors = dict((f.role_name(), text_type(ex)) for f, ex in self.errors)
             raise ValidationError(valerror_eid(entity.eid), errors)
         if eid is None: # creation or copy
             entity.eid = eid = self._insert_entity(etype, formparams['eid'], rqlquery)