Hello all

I've tried to correct our string handling by using sqlobject's UnicodeCol and stumbled a bit.

The following script produces errors when assigning the string or the unicode column:

# -- test.py
# -!- encoding: iso8859-1 -!-
import sqlobject
dbURI = 'mysql://user1:pass1@db-server/db1'
sqlobject.sqlhub.processConnection = sqlobject.connectionForURI(dbURI)
   
class A(sqlobject.SQLObject):
    aString         = sqlobject.StringCol(default = None)
    aUnicodeString  = sqlobject.UnicodeCol(default = None)
   
try: A.createTable()
except: pass
   
a = A()
a.aString           = 'gaääää'
a.aUnicodeString    = u'ga\u00ef\u00ef\u00ef'
# -- test.py

(The string I'm trying to assing contains german umlauts, just in case it won't display correctly...)

I would expect that at least the second assignment should be valid. But, as the first assignment's value is also a valid python string, shouldn't this be valid, too?

Do I need to change the sqlobject.sqlhub.processConnection's encoding property?

How is this done correctly?

Thanks a lot!
Bernhard

(And sorry for the messy signature...)
___________________________________________________________________

Disclaimer:


Diese Mitteilung ist nur fuer die Empfaengerin / den Empfaenger bestimmt.

Fuer den Fall, dass sie von nichtberechtigten Personen empfangen wird, bitten wir diese hoeflich, die Mitteilung an die ZKB zurueckzusenden und anschliessend die Mitteilung mit allen Anhaengen sowie allfaellige Kopien zu vernichten bzw. zu loeschen. Der Gebrauch der Information ist verboten.


This message is intended only for the named recipient and may contain confidential or privileged information.

If you have received it in error, please advise the sender by return e-mail and delete this message and any attachments. Any unauthorised use or dissemination of this information is strictly prohibited.