我重命名plone站点名称时的UnicodeDecodeError

时间:2013-03-15 02:44:11

标签: unicode plone

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网站的名称。我不知道它们之间有什么区别。 :(

1 个答案:

答案 0 :(得分:5)

您的网站在某些时候会将unicode内容编入索引,从而有效地破坏它们。这可能是由于旧的Plone错误,或附加或自定义代码错误的原因。

您可以尝试使用默认的Python编码设置为UTF-8来运行完整的重新索引来解决此问题。 以下不是生产网站的推荐程序;这只是一种临时的“膏药”。为了你的问题。

在Python site-packages目录中,添加名为sitecustomize.py的文件,其中包含以下内容:

import sys

sys.setdefaultencoding('utf8')

然后重新启动您的plone网站并尝试重命名或首先执行完整目录reindex。

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