Laurent RAHUEL a écrit :
When adding these lines into dev.cfg :

decodingFilter.on = True
decodingFilter.encoding = "utf8"

Nothing appends on the catwalk interface when trying to add amitié to a text filed. And I get these lines in the debug window :

(snip)

line 53, in beforeMain
    newValue = value.decode(enc)
File "/home/lrl/dev/turbogears/lang/python242/lib/python2.4/encodings/utf_8.py", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xe9 in position 5: unexpected end of data


Any ideas ???

Same problem here using SQLite. When I create a record with "éé" as title, I get :

Setup 1 :
 * StringCol
 * no decodingFilter specified in dev.cfg

 => title get saved as "'\xe9\xe9'"

Setup 2
 * StringCol
 * decodingFilter on, utf8

 => trace:
File "/usr/lib/python2.4/site-packages/CherryPy-2.1.0-py2.4.egg/cherrypy/lib/filter/decodingfilter.py", line 53, in beforeMain
    newValue = value.decode(enc)
  File "/usr/lib/python2.4/encodings/utf_8.py", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode bytes in position 0-1: unexpected end of data

Setup 3
 * replacing StringCol with UnicodeCol
 * no decodingFilter specified in dev.cfg

 => Now it's SQLObject that complains :(
    trace :
2005/12/04 18:32:36  INFO Traceback (most recent call last):
File "/usr/lib/python2.4/site-packages/CherryPy-2.1.0-py2.4.egg/cherrypy/_cphttptools.py", line 271, in run
    main()
File "/usr/lib/python2.4/site-packages/CherryPy-2.1.0-py2.4.egg/cherrypy/_cphttptools.py", line 502, in main
    body = page_handler(*args, **cherrypy.request.paramMap)
File "/usr/lib/python2.4/site-packages/TurboGears-0.9a0dev_r277-py2.4.egg/turbogears/controllers.py", line 198, in newfunc
    errors, errorhandler, func, *args, **kw)
File "/usr/lib/python2.4/site-packages/TurboGears-0.9a0dev_r277-py2.4.egg/turbogears/database.py", line 174, in run_with_transaction
    retval = func(*args, **kw)
File "/usr/lib/python2.4/site-packages/TurboGears-0.9a0dev_r277-py2.4.egg/turbogears/controllers.py", line 225, in _execute_func
    output = func(self, *args, **kw)
File "/usr/lib/python2.4/site-packages/TurboGears-0.9a0dev_r277-py2.4.egg/turbogears/catwalk/catwalk.py", line 696, in add
    new_object = eval(u'obj(%s)'% param_string)
  File "<string>", line 0, in ?
File "/usr/lib/python2.4/site-packages/SQLObject-0.7.0-py2.4.egg/sqlobject/main.py", line 1183, in __init__
    self._create(id, **kw)
File "/usr/lib/python2.4/site-packages/SQLObject-0.7.0-py2.4.egg/sqlobject/main.py", line 1207, in _create
    self.set(**kw)
File "/usr/lib/python2.4/site-packages/SQLObject-0.7.0-py2.4.egg/sqlobject/main.py", line 1073, in set
    value = to_python(dbValue, self._SO_validatorState)
File "/usr/lib/python2.4/site-packages/SQLObject-0.7.0-py2.4.egg/sqlobject/col.py", line 522, in to_python
    raise UnicodeDecodeError(*args)
UnicodeDecodeError: 'utf8' codec can't decode bytes in position 0-1: unexpected end of data - (self.db_encoding is : UTF-8)

(NB : I hacked sqlobject to add the db_encoding to the exception's infos)


Laurent, did you manage to get this stuff working ?

Reply via email to