首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Plone安全修补程序20161129后的UnicodeDecodeError在PloneFormGen中的应用

Plone安全修补程序20161129后的UnicodeDecodeError在PloneFormGen中的应用
EN

Stack Overflow用户
提问于 2016-12-03 13:20:20
回答 1查看 115关注 0票数 1

在应用Plone安全修补程序20161129之后,我们的PloneFormGen表单不再工作了,因为它包含了Umlauts (n,n,或PloneFormGen)。我们使用PloneFormGen 1.7.20,这是Plone 4.3.9的推荐版本。下面是堆栈跟踪:

代码语言:javascript
复制
  Module zope.tales.tales, line 696, in evaluate
   - URL: file:/var/plone/buildout-cache/eggs/Products.PloneFormGen-1.7.20-py2.7.egg/Products/PloneFormGen/skins/PloneFormGen/widget_fieldset_start.pt
   - Line 25, Column 10
   - Expression: <PythonExpr widget.Description(here)>
   - Names:
      {'container': <PloneSite at /mysite>,
       'context': <FormFolder at /mysite/mitglied-werden>,
       'desitelt': <object object at 0x7fe244f734b0>,
       'here': <FormFolder at /mysite/mitglied-werden>,
       'loop': {u'field': <Products.PageTemplates.Expressions.PathIterator object at 0x16fe5350>},
       'nothing': None,
       'options': {'args': (),
                   'state': <Products.CMFFormController.ControllerState.ControllerState object at 0x7fe22c676610>},
       'repeat': <Products.PageTemplates.Expressions.SafeMapping object at 0x1d61fc00>,
       'request': <HTTPRequest, URL=https://www.example.org/mitglied-werden/fg_base_view_p3>,
       'root': <Application at >,
       'template': <FSControllerPageTemplate at /mysite/fg_base_view_p3 used for /mysite/mitglied-werden>,
       'traverse_subpath': [],
       'user': <PloneUser 'siteb390'>}
  Module Products.PageTemplates.ZRPythonExpr, line 48, in __call__
   - __traceback_info__: widget.Description(here)
  Module PythonExpr, line 1, in <expression>
  Module Products.PloneFormGen.content.field_utils, line 27, in wDescription
  Module zope.i18n, line 107, in translate
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 20: ordinal not in range(128)

移除后,它再次工作,但这个表单现在看起来有点不专业了。

在搜索了一个小时的网页后,我不知道是哪个扩展导致了这个错误(PloneFormGen?)导致这个问题以及如何解决这个问题:-/甚至不知道该往哪个方向看.

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-12-05 16:25:58

从1.7.20开始,所有PFG描述字段都通过转换机制推入。(请不要问我为什么用户提供的字段会这样做,因为description字段一开始并不是语言不敏感的。)它对您可以在描述中使用的字母施加了额外的限制,正如您已经发现的那样。

并不声称这是一个错误修复,但在我的快速试验中,修改了buildout-cache/eggs/Products.PloneFormGen-1.7.20-py2.7.egg/Products/PloneFormGen/content/field_utils.py第27行

代码语言:javascript
复制
        if value:
        value = translate(value, context=instance.REQUEST)
        return cgi.escape(value)

代码语言:javascript
复制
    if value:
        value = translate(value.decode('utf-8'), context=instance.REQUEST)
        return cgi.escape(value)

解决了问题。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40948196

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档