Character encoding Plone/Dextrity架构。选择不允许使用西班牙语字符

Character encoding Plone/Dextrity架构。选择不允许使用西班牙语字符,character-encoding,plone,dexterity,Character Encoding,Plone,Dexterity,在Plone 4.1.2中,我创建了一个灵活的MyContent类型。它有3个zope.schema.Choice字段。其中两个从硬编码词汇表中获取值,另一个从动态词汇表中获取值。在这两种情况下,如果我选择了一个带有西班牙语口音的值,当我保存add表单时,所选内容将消失,并且不会显示在视图表单中(不会显示任何错误消息)。但如果我选择一个非重音值,一切都会正常 有没有关于如何解决这个问题的建议 (大卫;我希望这就是你要我做的事) Plone使用gettext进行国际化。防弹方法是用英语实现您的自定

在Plone 4.1.2中,我创建了一个灵活的MyContent类型。它有3个
zope.schema.Choice
字段。其中两个从硬编码词汇表中获取值,另一个从动态词汇表中获取值。在这两种情况下,如果我选择了一个带有西班牙语口音的值,当我保存add表单时,所选内容将消失,并且不会显示在视图表单中(不会显示任何错误消息)。但如果我选择一个非重音值,一切都会正常

有没有关于如何解决这个问题的建议

(大卫;我希望这就是你要我做的事)


Plone使用
gettext
进行国际化。防弹方法是用英语实现您的自定义功能,并为您的特定语言使用
locales
。由于您已经设置了一个
MessageFactory
,您甚至可以使用一个工具,例如用于快速提取消息字符串。

我找到了部分解释/解决方案。如果我执行以下操作,我可以在视图表单中获取西班牙语字符:

--编码:utf-8-- 从plone.directions导入表单 来自五个进口国 从zope导入模式 从plone.com导入表单,灵巧 从zope.schema.vocabulary导入SimpleVocabulary

myVocabulary=SimpleVocabulary.fromItems(( (u“Foo”、“id_foó”), (你说的是“男爵”,“我说的是男爵”)

IPrueba类(form.Schema):


几个月前,我在早期开发中发现了同样的问题

词汇表上的标记必须规范化;我就是这样解决的:

# -*- coding: utf-8 -*-

import unicodedata

…

class SectionsVocabulary(object):
    """Creates a vocabulary with the sections stored in the registry; the
    vocabulary is normalized to allow the use of non-ascii characters.
    """
    grok.implements(IVocabularyFactory)

    def __call__(self, context):
        registry = getUtility(IRegistry)
        settings = registry.forInterface(INITFSettings)
        items = []
        for section in settings.sections:
            token = unicodedata.normalize('NFKD', section).encode('ascii', 'ignore').lower()
            items.append(SimpleVocabulary.createTerm(section, token, section))
        return SimpleVocabulary(items)

grok.global_utility(SectionsVocabulary, name=u'collective.nitf.Sections')

告诉我们有关词汇表选项的字符编码。在buildout.cfg中,我添加了:[cmds]recipe=plone.recipe.command update command=${cmds:command}command=chmod 600.installed.cfg cat>${buildout:directory}/bin/sitecustomize.py…如果我删除我添加到构建中的内容,结果是一样的。你能更新问题以显示你用来设置词汇表的代码吗?我在中找到了部分解释/解决方案。如果我执行以下操作,我可以在视图表单中获取西班牙语字符:
tipoMenu = schema.Choice(
        title=_(u"Tipo de evento"),
        description=_(u"Marque la opción que aplique o "
                       "seleccione otro si ninguna aplica"),
        vocabulary=myVocabulary,
        required=False,
    )   
# -*- coding: utf-8 -*-

import unicodedata

…

class SectionsVocabulary(object):
    """Creates a vocabulary with the sections stored in the registry; the
    vocabulary is normalized to allow the use of non-ascii characters.
    """
    grok.implements(IVocabularyFactory)

    def __call__(self, context):
        registry = getUtility(IRegistry)
        settings = registry.forInterface(INITFSettings)
        items = []
        for section in settings.sections:
            token = unicodedata.normalize('NFKD', section).encode('ascii', 'ignore').lower()
            items.append(SimpleVocabulary.createTerm(section, token, section))
        return SimpleVocabulary(items)

grok.global_utility(SectionsVocabulary, name=u'collective.nitf.Sections')