6

Plone 4.2.5从4.1.4升级,default_language为zh-cn,default_charset为utf-8(portal_properties/site_properties)。

当我尝试在 ip:8080/ 的根页面中重命名 Plone 站点的名称时,会显示站点错误:

An error was encountered while publishing this resource. 
Error Type: UnicodeDecodeError
Error Value: ('ascii', '\xe8\xa2\x81\xe4\xba\x88\xe6\xb9\x98', 0, 1, 'ordinal not in range(128)')

Traceback (innermost last):
  Module ZPublisher.Publish, line 126, in publish
  Module ZPublisher.mapply, line 77, in mapply
  Module ZPublisher.Publish, line 46, in call_object
  Module OFS.CopySupport, line 333, in manage_renameObjects
  Module OFS.CopySupport, line 369, in manage_renameObject
  Module zope.event, line 31, in notify
  Module zope.component.event, line 24, in dispatch
  Module zope.component._api, line 136, in subscribers
  Module zope.component.registry, line 321, in subscribers
  Module zope.interface.adapter, line 585, in subscribers
  Module zope.component.event, line 32, in objectEventNotify
  Module zope.component._api, line 136, in subscribers
  Module zope.component.registry, line 321, in subscribers
  Module zope.interface.adapter, line 585, in subscribers
  Module OFS.subscribers, line 101, in dispatchObjectWillBeMovedEvent
  Module zope.container.contained, line 153, in dispatchToSublocations
  Module zope.component._api, line 136, in subscribers
  Module zope.component.registry, line 321, in subscribers
  Module zope.interface.adapter, line 585, in subscribers
  Module OFS.subscribers, line 101, in dispatchObjectWillBeMovedEvent
  Module zope.container.contained, line 153, in dispatchToSublocations
  Module zope.component._api, line 136, in subscribers
  Module zope.component.registry, line 321, in subscribers
  Module zope.interface.adapter, line 585, in subscribers
  Module OFS.subscribers, line 101, in dispatchObjectWillBeMovedEvent
  Module zope.container.contained, line 153, in dispatchToSublocations
  Module zope.component._api, line 136, in subscribers
  Module zope.component.registry, line 321, in subscribers
  Module zope.interface.adapter, line 585, in subscribers
  Module OFS.subscribers, line 101, in dispatchObjectWillBeMovedEvent
  Module zope.container.contained, line 153, in dispatchToSublocations
  Module zope.component._api, line 136, in subscribers
  Module zope.component.registry, line 321, in subscribers
  Module zope.interface.adapter, line 585, in subscribers
  Module OFS.subscribers, line 101, in dispatchObjectWillBeMovedEvent
  Module zope.container.contained, line 153, in dispatchToSublocations
  Module zope.component._api, line 136, in subscribers
  Module zope.component.registry, line 321, in subscribers
  Module zope.interface.adapter, line 585, in subscribers
  Module Products.CMFCore.CMFCatalogAware, line 271, in handleContentishEvent
  Module Products.Archetypes.CatalogMultiplex, line 49, in unindexObject
  Module Products.CMFPlone.CatalogTool, line 393, in uncatalog_object
  Module Products.ZCatalog.ZCatalog, line 508, in uncatalog_object
  Module Products.ZCatalog.Catalog, line 369, in uncatalogObject
  Module Products.PluginIndexes.common.UnIndex, line 286, in unindex_object
  Module Products.PluginIndexes.common.UnIndex, line 157, in removeForwardIndexEntry
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe8 in position 0: ordinal not in range(128)

当我尝试将一些文件夹导入新创建的 Plone 站点时,曾经发生过与 UnicodeDecodeError 相关的问题。

我成功地重命名了另一个 Plone 站点的名称。我不知道它们之间有什么区别。:(

4

1 回答 1

5

您的网站有时会将 unicode 内容编入目录索引,从而有效地破坏它们。这可能是由于旧的 Plone 错误,或者附加组件或自定义代码出错。

您可以尝试运行一个完整的重新索引,并将默认的 Python 编码设置为 UTF-8 来解决这个问题。以下不是生产现场的推荐程序;这只是解决您问题的临时“石膏”。

在您的 Pythonsite-packages目录中,添加一个以sitecustomize.py内容命名的文件:

import sys

sys.setdefaultencoding('utf8')

然后重新启动您的克隆站点并尝试重命名或首先执行完整的目录重新索引。

请记住再次删除sitecustomize.py文件。在 Python 中设置默认编码只会掩盖未来的问题。

于 2013-03-15T10:10:51.447 回答