[html gen] Avoid encoding error for non-ascii values
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 03 Nov 2016 18:28:25 +0100
changeset 1958 3e304ec4cff8
parent 1957 b62759f45f71
child 1959 e12e9e564de0
[html gen] Avoid encoding error for non-ascii values .format on encoded string will attempt to encode its parameters, unlike the % operator which will unicode the format string.
entities/html_generation.py
--- a/entities/html_generation.py	Thu Nov 03 18:27:10 2016 +0100
+++ b/entities/html_generation.py	Thu Nov 03 18:28:25 2016 +0100
@@ -277,10 +277,10 @@
                 href = value.absolute_url()
                 label = _concept_value(value, 'seda-2')
                 if value.label() != label:
-                    label = '{0} ({1})'.format(label, value.label())
+                    label = u'{0} ({1})'.format(label, value.label())
             elif hasattr(value, 'id'):
                 # value is something in the profile which has a id (e.g. archive unit, data object)
-                href, label = '#{0}'.format(value.id), value.id
+                href, label = u'#{0}'.format(value.id), value.id
             else:
                 return None  # intermediary entity
             return self.element('a', self.element('span', attributes={'class': 'value'}),