Re: [Modeling-users] type('') and unicode
Status: Abandoned
Brought to you by:
sbigaret
From: Yannick G. <yan...@sa...> - 2003-07-16 18:06:06
|
=2D----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On July 16, 2003 11:44 am, you wrote: > > UnicodeError: ASCII encoding error: ordinal not in range(128) > > > > Argh ! > > U get this cause you try to to something like this > ' %s ' % my_unicode It seems to be fine here : >>> "%s" % u"=E9=E9" u'\xe9\xe9' it's the print (or write()) that may choke : >>> print u"=E9=E9" Traceback (most recent call last): File "<stdin>", line 1, in ? UnicodeError: ASCII encoding error: ordinal not in range(128) > Could you please give us a bigger traceback. > I talk w/ Sebastian last week about this. In fact i got some > trouble w/ mysql and unicode (not using modeling), and ask > him what he did to cover this issue in modeling. sure ! File "/usr/lib/python2.2/site-packages/Modeling/EditingContext.py", line 1304, in fetch return self.objectsWithFetchSpecification(fs) File "/usr/lib/python2.2/site-packages/Modeling/EditingContext.py", line 1218, in objectsWithFetchSpecification objects=3Dself.parentObjectStore().objectsWithFetchSpecification(fs, ec) File "/usr/lib/python2.2/site-packages/Modeling/ObjectStoreCoordinator.py= ", line 420, in objectsWithFetchSpecification return store.objectsWithFetchSpecification(aFetchSpecification, anEditingContext) File "/usr/lib/python2.2/site-packages/Modeling/DatabaseContext.py", line 1521, in objectsWithFetchSpecification anEditingContext) File "/usr/lib/python2.2/site-packages/Modeling/DatabaseChannel.py", line 381, in selectObjectsWithFetchSpecification entity) File "/usr/lib/python2.2/site-packages/Modeling/DatabaseAdaptors/AbstractDBAPI2A= daptorLayer/AbstractDBAPI2AdaptorChannel.py", line 295, in selectAttributes db_error(msg) File "/usr/lib/python2.2/site-packages/Modeling/logging.py", line 56, in log_stderr sys.stderr.write('%s\n'%msg) UnicodeError: ASCII encoding error: ordinal not in range(128) The unicode error is trigered by logging that tries to repport an error, probably a unicode error... > It's really seem that modeling doesn't take care about unicode. > (Read : Seb hasn't done so much test about unicode ) > > > I haven't done so much test but i think that stuff like enabling > LOG will generate a lot of Unicode traceback > > > there is "type(foo) in (type(''), type(u''))" or I could encode my > > query or who knows what. Since some RDMS (aka MySQL) choke on > > unicode, maybe it would be best to have every queries encoded in utf-8 > > but I prefer to have your opinion 1st. > > Another trick that might help you is that MySQL 4.0 support unicode > in query. but the MySQLDB don't by default. In fact you can pass > a special encoding charset at connection but you need to have > a latest version of the package ( I have to re-build this from source > on my debian since it isn't in the default unstable install) What I said earlier is that I manually utf-8 encode every thing the I *store* in the DB. I thought that I might be safe with queries but well, utf-8 encoding queries too is not that much work. =2D -- Yannick Gingras Byte Gardener, Savoir-faire Linux inc. (514) 276-5468 =2D----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQE/FZP1rhy5Fqn/MRARAuAIAJ9auY2Kr0NgPBCma8l4UmVIU/ofhQCcCbdv qB80k8Vua8izSSILdmgY3L0=3D =3DUCaV =2D----END PGP SIGNATURE----- |