On 9/10/06, Oleg Broytmann <[EMAIL PROTECTED]> wrote:
On Sun, Sep 10, 2006 at 02:41:02PM +0200, Markus Gritsch wrote:
> The following code worked in SQLObject-0.7.1b1 but raises an exception
> when with SQLObject-0.7.1rc1:
>
> # -*- coding: latin-1 -*-
>
> from sqlobject import *
>
> sqlhub.processConnection = connectionForURI('mysql://[EMAIL PROTECTED]/test')
>
> class Test(SQLObject):
>     name = UnicodeCol()
>
> Test.createTable(ifNotExists=True)
> Test(name=u'sch?n')

[skip]

>     myquery = unicode(query, self.encoding)
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position
> 36: ordinal not in range(128)

   self.encoding here is "ascii". Change the encoding:

sqlhub.processConnection = connectionForURI('mysql://[EMAIL 
PROTECTED]/test?sqlobject_encoding=latin1')

Thank you for your help.  Yes, this prevents from the exception and
results in the same entry in the DB as when using 7.1b1.  However,
when using "MySQL Query Browser" one can see, that latin-1 is not
really what I want (attachment shot1.png).  I would like to save the
data utf-8 encoded (which would look like shot2.png), but when using

sqlhub.processConnection =
connectionForURI('mysql://[EMAIL PROTECTED]/test?sqlobject_encoding=utf8')

I get another traceback:

Traceback (most recent call last):
 File "test.py", line 11, in ?
   Test(name=u'schön')
 File 
"c:\python24\lib\site-packages\sqlobject-0.7.1rc1-py2.4.egg\sqlobject\declarative.py",
line 93, in _wrapper
   return fn(self, *args, **kwargs)
 File 
"c:\python24\lib\site-packages\sqlobject-0.7.1rc1-py2.4.egg\sqlobject\main.py",
line 1198, in __init__
   self._create(id, **kw)
 File 
"c:\python24\lib\site-packages\sqlobject-0.7.1rc1-py2.4.egg\sqlobject\main.py",
line 1225, in _create
   self._SO_finishCreate(id)
 File 
"c:\python24\lib\site-packages\sqlobject-0.7.1rc1-py2.4.egg\sqlobject\main.py",
line 1252, in _SO_finishCreate
   self._init(id)
 File 
"c:\python24\lib\site-packages\sqlobject-0.7.1rc1-py2.4.egg\sqlobject\main.py",
line 959, in _init
   self._SO_selectInit(selectResults)
 File 
"c:\python24\lib\site-packages\sqlobject-0.7.1rc1-py2.4.egg\sqlobject\main.py",
line 1150, in _SO_selectInit
   colValue = col.to_python(colValue, self._SO_validatorState)
 File 
"c:\python24\lib\site-packages\sqlobject-0.7.1rc1-py2.4.egg\sqlobject\col.py",
line 543, in to_python
   return unicode(value, self.db_encoding)
 File "C:\Python24\lib\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 3-4:
unexpected end of data

Attachment: shot1.png
Description: PNG image

Attachment: shot2.png
Description: PNG image

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
sqlobject-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to