在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.