[form] apply patch #933771: format_single_value / vocabulary methods should *always* return actual value as an unicode string
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 21 Jun 2010 15:58:13 +0200
changeset 5816 5d72fbba92e9
parent 5815 282194aa43f3
child 5818 6d8c479fcd98
[form] apply patch #933771: format_single_value / vocabulary methods should *always* return actual value as an unicode string
web/formfields.py
--- a/web/formfields.py	Mon Jun 21 15:34:46 2010 +0200
+++ b/web/formfields.py	Mon Jun 21 15:58:13 2010 +0200
@@ -949,7 +949,7 @@
     linkedto = entity.linked_to(rtype, role)
     if linkedto:
         buildent = entity._cw.entity_from_eid
-        return [(buildent(eid).view('combobox'), eid) for eid in linkedto]
+        return [(buildent(eid).view('combobox'), unicode(eid)) for eid in linkedto]
     return []
 
 def relvoc_init(entity, rtype, role, required=False):
@@ -960,7 +960,7 @@
     # vocabulary doesn't include current values, add them
     if entity.has_eid():
         rset = entity.related(rtype, role)
-        vocab += [(e.view('combobox'), e.eid) for e in rset.entities()]
+        vocab += [(e.view('combobox'), unicode(e.eid)) for e in rset.entities()]
     return vocab
 
 def relvoc_unrelated(entity, rtype, role, limit=None):
@@ -1050,7 +1050,7 @@
             form.formvalues[(self, form)] = value
 
     def format_single_value(self, req, value):
-        return value
+        return unicode(value)
 
     def process_form_value(self, form):
         """process posted form and return correctly typed value"""