在zope实例所采用的python的路径中,找到site-packages目录,在此目录中建立一个sitecustomize.py文件,设置相应的权限。文件的内容如下:
import sys
sys.setdefaultencoding("utf-8")
重启zope实例,这样将解决很多unicodedecodeerror错误。
=========================================
#for python2.7 on ubuntu
/etc/python2.7/sitecustomize.py
#for python2.6 on centOS
/usr/local/lib/python2.6/site-packages/sitecustomize.py
=========================================
http://www.grabner-online.de/div_into/html/ch09s04s03.html
# sitecustomize.py
# this file can be anywhere in your Python path,
# but it usually goes in ${pythondir}/lib/site-packages/
import sys
sys.setdefaultencoding('iso-8859-1')
sitecustomize.py is a special script; Python will try to import it on startup, so any code in it will be run automatically. As the comment mentions, it can go anywhere (as long as import can find it), but it usually goes in the site-packages directory within your Python lib directory.
setdefaultencoding function sets, well, the default encoding. This is the encoding scheme that Python will try to use whenever it needs to auto-coerce a unicode string into a regular string.