idgserpro
(Idgserpro)
1
Take the following snippet of code:
field_vocabulary = SimpleVocabulary(
[SimpleTerm(value=u'Apresentação'.encode('utf8'), title='Apresentação'),
SimpleTerm(value=u'Relatório'.encode('utf8'), title='Relatório'),
])
(...)
field = schema.Choice(
title=_(u'field_title'),
description=_(u'field_description'),
required=True,
vocabulary=field_vocabulary,
)
Problem is: since this field is required, it never validates because u'Apresentação
is non ascii and in https://github.com/zopefoundation/z3c.form/blob/3.2.11/src/z3c/form/validator.py#L48 value comes as None
!, if I change it for u'Apresentacao
it works.
@mauritsvanrees or @hvelarde, have you ever come across this kind of problem?
EDIT: The problem seems worse: if it's not required and the value of my SimpleTerm is non-ascii, it's persisted as None
.
datakurre
(Asko Soukka)
2
Non-ascii values should still have ascii token for SimpleTerm(value=, token=, title=).
You could possible use id normalizer from plone.i18n to make ascii versions.
1 Like
idgserpro
(Idgserpro)
3
Just check https://docs.plone.org/develop/plone/forms/vocabularies.html#vocabulary-terms. Any reason why it must be ascii? Why schema.TextLine can have non ascii and a SimpleTerm can't in it's token?
hvelarde
(hvelarde)
4
it has to be ASCII because that's the way it is; check the following code (but use plone.i18n instead):
idgserpro
(Idgserpro)
5
Having the token with ascii, I can have a non ascii value with no issues. Thanks @datakurre.
Not really the answer we were looking for but truth is always hard.
1 Like