# HG changeset patch # User Aurelien Campeas # Date 1303482296 -7200 # Node ID 86bbf174e463cf27d97b0526d731ac39eae2ede7 # Parent f20fc41e3f7d758c2a76cf626f7cd236a0b6c021 [facets] fix unicode encode error; closes #1625112 diff -r f20fc41e3f7d -r 86bbf174e463 web/facet.py --- a/web/facet.py Fri Apr 22 16:15:10 2011 +0200 +++ b/web/facet.py Fri Apr 22 16:24:56 2011 +0200 @@ -451,6 +451,11 @@ return False +def encode(obj, encoding): + if isinstance(obj, unicode): + return obj.encode(encoding) + return unicode(obj).encode(encoding) + class RelationFacet(VocabularyFacet): """Base facet to filter some entities according to other entities to which they are related. Create concret facet by inheriting from this class an then @@ -605,7 +610,8 @@ insert_attr_select_relation( rqlst, self.filtered_variable, self.rtype, self.role, self.target_attr, select_target_entity=False) - values = [str(x) for x, in self.rqlexec(rqlst.as_string())] + encoding = self._cw.encoding + values = [encode(x, encoding) for x, in self.rqlexec(rqlst.as_string())] except: self.exception('while computing values for %s', self) return []