[Grok-dev] Re: Understanding unicode

Jan Ulrich Hasecke janulrich.hasecke at web.de
Fri Aug 31 15:14:08 EDT 2007


Am 31.08.2007 um 20:40 schrieb Martijn Faassen:
> Jan Ulrich Hasecke wrote:
>> Hi,
>> I use a Choice in grok.Fields.
>> form_fields = grok.Fields(
>>     name=Choice(title=u'Art', values=[u'Elefantengehege',  
>> u'Giraffengehege', u'Paviankaefig'])
>> When I insert u'Paviankäfig' I get an unicode error.
>>  UnicodeEncodeError: 'ascii' codec can't encode characters in  
>> position 7-8: ordinal not in range(128)
>> I used name=Affenkäfig before though.
>
> It would be helpful if you gave a longer traceback so we can see  
> where in the code you get the unicode error. Do you get this during  
> runtime or during startup time?
>

During startup: (I inserted # -*- coding: UTF-8 -*-  at the top of  
the file, no effect.)

Macintosh-2:~/GrokZoo juh$ ./bin/zopectl fg
/Users/juh/GrokZoo/parts/app/runzope -C /Users/juh/GrokZoo/parts/ 
zopectl/zope.conf
Traceback (most recent call last):
   File "/Users/juh/GrokZoo/parts/app/runzope", line 107, in ?
     zope.app.twisted.main.main()
   File "/Users/juh/buildout-eggs/tmp_JdxsP/ 
zope.app.twisted-3.4.0b1_r76119-py2.4.egg/zope/app/twisted/main.py",  
line 74, in main
   File "/Users/juh/buildout-eggs/tmp_JdxsP/ 
zope.app.twisted-3.4.0b1_r76119-py2.4.egg/zope/app/twisted/main.py",  
line 145, in setup
   File "/Users/juh/buildout-eggs/tmpNn-RO6/zope.app.appsetup-3.4.0a1- 
py2.4.egg/zope/app/appsetup/appsetup.py", line 110, in config
   File "/Users/juh/buildout-eggs/tmpSiL1m9/ 
zope.configuration-3.4.0b1-py2.4.egg/zope/configuration/ 
xmlconfig.py", line 610, in file
   File "/Users/juh/buildout-eggs/tmpSiL1m9/ 
zope.configuration-3.4.0b1-py2.4.egg/zope/configuration/ 
xmlconfig.py", line 546, in include
   File "/Users/juh/buildout-eggs/tmpSiL1m9/ 
zope.configuration-3.4.0b1-py2.4.egg/zope/configuration/ 
xmlconfig.py", line 378, in processxmlfile
   File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ 
python2.4/xml/sax/expatreader.py", line 107, in parse
     xmlreader.IncrementalParser.parse(self, source)
   File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ 
python2.4/xml/sax/xmlreader.py", line 123, in parse
     self.feed(buffer)
   File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ 
python2.4/xml/sax/expatreader.py", line 207, in feed
     self._parser.Parse(data, isFinal)
   File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ 
python2.4/xml/sax/expatreader.py", line 348, in end_element_ns
     self._cont_handler.endElementNS(pair, None)
   File "/Users/juh/buildout-eggs/tmpSiL1m9/ 
zope.configuration-3.4.0b1-py2.4.egg/zope/configuration/ 
xmlconfig.py", line 357, in endElementNS
   File "/Users/juh/buildout-eggs/tmpSiL1m9/ 
zope.configuration-3.4.0b1-py2.4.egg/zope/configuration/config.py",  
line 542, in end
   File "/Users/juh/buildout-eggs/tmpSiL1m9/ 
zope.configuration-3.4.0b1-py2.4.egg/zope/configuration/config.py",  
line 690, in finish
   File "/Users/juh/buildout-eggs/tmpSiL1m9/ 
zope.configuration-3.4.0b1-py2.4.egg/zope/configuration/ 
xmlconfig.py", line 546, in include
   File "/Users/juh/buildout-eggs/tmpSiL1m9/ 
zope.configuration-3.4.0b1-py2.4.egg/zope/configuration/ 
xmlconfig.py", line 378, in processxmlfile
   File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ 
python2.4/xml/sax/expatreader.py", line 107, in parse
     xmlreader.IncrementalParser.parse(self, source)
   File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ 
python2.4/xml/sax/xmlreader.py", line 123, in parse
     self.feed(buffer)
   File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ 
python2.4/xml/sax/expatreader.py", line 207, in feed
     self._parser.Parse(data, isFinal)
   File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ 
python2.4/xml/sax/expatreader.py", line 348, in end_element_ns
     self._cont_handler.endElementNS(pair, None)
   File "/Users/juh/buildout-eggs/tmpSiL1m9/ 
zope.configuration-3.4.0b1-py2.4.egg/zope/configuration/ 
xmlconfig.py", line 357, in endElementNS
   File "/Users/juh/buildout-eggs/tmpSiL1m9/ 
zope.configuration-3.4.0b1-py2.4.egg/zope/configuration/config.py",  
line 542, in end
   File "/Users/juh/buildout-eggs/tmpSiL1m9/ 
zope.configuration-3.4.0b1-py2.4.egg/zope/configuration/config.py",  
line 690, in finish
   File "/Users/juh/buildout-eggs/grok-0.10-py2.4.egg/grok/zcml.py",  
line 33, in grokDirective
     grok.grok(package.__name__)
   File "/Users/juh/buildout-eggs/grok-0.10-py2.4.egg/grok/_grok.py",  
line 81, in do_grok
     martian.grok_dotted_name(dotted_name, the_module_grokker)
   File "/Users/juh/buildout-eggs/martian-0.8.1-py2.4.egg/martian/ 
core.py", line 193, in grok_dotted_name
     grok_package(module_info, grokker, **kw)
   File "/Users/juh/buildout-eggs/martian-0.8.1-py2.4.egg/martian/ 
core.py", line 198, in grok_package
     grok_package(sub_module_info, grokker, **kw)
   File "/Users/juh/buildout-eggs/martian-0.8.1-py2.4.egg/martian/ 
core.py", line 196, in grok_package
     grok_module(module_info, grokker, **kw)
   File "/Users/juh/buildout-eggs/martian-0.8.1-py2.4.egg/martian/ 
core.py", line 201, in grok_module
     grokker.grok(module_info.dotted_name, module_info.getModule(),  
**kw)
   File "/Users/juh/buildout-eggs/martian-0.8.1-py2.4.egg/martian/ 
scan.py", line 116, in getModule
Macintosh-2:~/GrokZoo juh$ ./bin/zopectl fg
/Users/juh/GrokZoo/parts/app/runzope -C /Users/juh/GrokZoo/parts/ 
zopectl/zope.conf
Traceback (most recent call last):
   File "/Users/juh/GrokZoo/parts/app/runzope", line 107, in ?
     zope.app.twisted.main.main()
   File "/Users/juh/buildout-eggs/tmp_JdxsP/ 
zope.app.twisted-3.4.0b1_r76119-py2.4.egg/zope/app/twisted/main.py",  
line 74, in main
   File "/Users/juh/buildout-eggs/tmp_JdxsP/ 
zope.app.twisted-3.4.0b1_r76119-py2.4.egg/zope/app/twisted/main.py",  
line 145, in setup
   File "/Users/juh/buildout-eggs/tmpNn-RO6/zope.app.appsetup-3.4.0a1- 
py2.4.egg/zope/app/appsetup/appsetup.py", line 110, in config
   File "/Users/juh/buildout-eggs/tmpSiL1m9/ 
zope.configuration-3.4.0b1-py2.4.egg/zope/configuration/ 
xmlconfig.py", line 610, in file
   File "/Users/juh/buildout-eggs/tmpSiL1m9/ 
zope.configuration-3.4.0b1-py2.4.egg/zope/configuration/ 
xmlconfig.py", line 546, in include
   File "/Users/juh/buildout-eggs/tmpSiL1m9/ 
zope.configuration-3.4.0b1-py2.4.egg/zope/configuration/ 
xmlconfig.py", line 378, in processxmlfile
   File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ 
python2.4/xml/sax/expatreader.py", line 107, in parse
     xmlreader.IncrementalParser.parse(self, source)
   File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ 
python2.4/xml/sax/xmlreader.py", line 123, in parse
     self.feed(buffer)
   File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ 
python2.4/xml/sax/expatreader.py", line 207, in feed
     self._parser.Parse(data, isFinal)
   File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ 
python2.4/xml/sax/expatreader.py", line 348, in end_element_ns
     self._cont_handler.endElementNS(pair, None)
   File "/Users/juh/buildout-eggs/tmpSiL1m9/ 
zope.configuration-3.4.0b1-py2.4.egg/zope/configuration/ 
xmlconfig.py", line 357, in endElementNS
   File "/Users/juh/buildout-eggs/tmpSiL1m9/ 
zope.configuration-3.4.0b1-py2.4.egg/zope/configuration/config.py",  
line 542, in end
   File "/Users/juh/buildout-eggs/tmpSiL1m9/ 
zope.configuration-3.4.0b1-py2.4.egg/zope/configuration/config.py",  
line 690, in finish
   File "/Users/juh/buildout-eggs/tmpSiL1m9/ 
zope.configuration-3.4.0b1-py2.4.egg/zope/configuration/ 
xmlconfig.py", line 546, in include
   File "/Users/juh/buildout-eggs/tmpSiL1m9/ 
zope.configuration-3.4.0b1-py2.4.egg/zope/configuration/ 
xmlconfig.py", line 378, in processxmlfile
   File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ 
python2.4/xml/sax/expatreader.py", line 107, in parse
     xmlreader.IncrementalParser.parse(self, source)
   File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ 
python2.4/xml/sax/xmlreader.py", line 123, in parse
     self.feed(buffer)
   File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ 
python2.4/xml/sax/expatreader.py", line 207, in feed
     self._parser.Parse(data, isFinal)
   File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ 
python2.4/xml/sax/expatreader.py", line 348, in end_element_ns
     self._cont_handler.endElementNS(pair, None)
   File "/Users/juh/buildout-eggs/tmpSiL1m9/ 
zope.configuration-3.4.0b1-py2.4.egg/zope/configuration/ 
xmlconfig.py", line 357, in endElementNS
   File "/Users/juh/buildout-eggs/tmpSiL1m9/ 
zope.configuration-3.4.0b1-py2.4.egg/zope/configuration/config.py",  
line 542, in end
   File "/Users/juh/buildout-eggs/tmpSiL1m9/ 
zope.configuration-3.4.0b1-py2.4.egg/zope/configuration/config.py",  
line 690, in finish
   File "/Users/juh/buildout-eggs/grok-0.10-py2.4.egg/grok/zcml.py",  
line 33, in grokDirective
     grok.grok(package.__name__)
   File "/Users/juh/buildout-eggs/grok-0.10-py2.4.egg/grok/_grok.py",  
line 81, in do_grok
     martian.grok_dotted_name(dotted_name, the_module_grokker)
   File "/Users/juh/buildout-eggs/martian-0.8.1-py2.4.egg/martian/ 
core.py", line 193, in grok_dotted_name
     grok_package(module_info, grokker, **kw)
   File "/Users/juh/buildout-eggs/martian-0.8.1-py2.4.egg/martian/ 
core.py", line 198, in grok_package
     grok_package(sub_module_info, grokker, **kw)
   File "/Users/juh/buildout-eggs/martian-0.8.1-py2.4.egg/martian/ 
core.py", line 196, in grok_package
     grok_module(module_info, grokker, **kw)
   File "/Users/juh/buildout-eggs/martian-0.8.1-py2.4.egg/martian/ 
core.py", line 201, in grok_module
     grokker.grok(module_info.dotted_name, module_info.getModule(),  
**kw)
   File "/Users/juh/buildout-eggs/martian-0.8.1-py2.4.egg/martian/ 
scan.py", line 116, in getModule
     self._module = resolve(self.dotted_name)
   File "/Users/juh/buildout-eggs/martian-0.8.1-py2.4.egg/martian/ 
scan.py", line 154, in resolve
     __import__(used)
   File "/Users/juh/GrokZoo/src/grokzoo/zoo.py", line 47, in ?
     class ElefantenGehegeBauen(grok.AddForm):
   File "/Users/juh/GrokZoo/src/grokzoo/zoo.py", line 51, in  
ElefantenGehegeBauen
     form_fields = grok.Fields(
   File "/Users/juh/buildout-eggs/tmpa_oDQ6/ 
zope.schema-3.4.0b1dev_r77624-py2.4.egg/zope/schema/_field.py", line  
251, in __init__
   File "/Users/juh/buildout-eggs/tmpa_oDQ6/ 
zope.schema-3.4.0b1dev_r77624-py2.4.egg/zope/schema/vocabulary.py",  
line 98, in fromValues
   File "/Users/juh/buildout-eggs/tmpa_oDQ6/ 
zope.schema-3.4.0b1dev_r77624-py2.4.egg/zope/schema/vocabulary.py",  
line 108, in createTerm
   File "/Users/juh/buildout-eggs/tmpa_oDQ6/ 
zope.schema-3.4.0b1dev_r77624-py2.4.egg/zope/schema/vocabulary.py",  
line 41, in __init__
zope.configuration.xmlconfig.ZopeXMLConfigurationError: File "/Users/ 
juh/GrokZoo/parts/app/site.zcml", line 4.0-4.29
     ZopeXMLConfigurationError: File "/Users/juh/GrokZoo/src/grokzoo/ 
configure.zcml", line 4.2-4.27
     UnicodeEncodeError: 'ascii' codec can't encode character u'\xe4'  
in position 7: ordinal not in range(128)


juh

-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 186 bytes
Desc: Signierter Teil der Nachricht
Url : http://mail.zope.org/pipermail/grok-dev/attachments/20070831/a59d135d/PGP.bin


More information about the Grok-dev mailing list