Am Montag, den 23.05.2005, 10:35 +0200 schrieb Joern Wallstabe:
Hello,
i would like to feed a zpt form with data from a python dictionary via a python script
zpt snippet:
<textarea name="title:record:ulines" rows="3" cols="65"> <tal:span content="python:context.printDict(here.dict)"/>
This is wrong anyway. Use tal:content in the textarea instead.
</textarea>
python script prinDict:
keys_ = dict.keys() keys_.sort() lines=[]
for key in keys_: lines.append(u"%s:%s\n" %(key ,dict[key]))
uni_str = u"".join(lines) return uni_str.encode('utf-8')
I'm always getting a UnicodeDecodeError.
I' using Zope 2.7.5, CMF 1.5.1, Python 2.3.5 HTML meta tag is set to <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> CMF default_charset = utf-8
meta charset does not count btw. CMF default should, but it really depends on the real content-type header you send. Make sure its the encoding you want there (setHeader() ) And its important to watch the encoding of the strings you work with. Where does the dictionary come from?