How do I get the encoding done for passing data to the database?

0 views
Skip to first unread message

mar...@sismografo.es

unread,
Jul 3, 2007, 7:34:42 AM7/3/07
to TurboGears
I am having quite a bad time with the type encoding. (using spanish
accents). In order to get the string literals working I convert them
to unicode without problems (I first had to figure out that this is
necessary).
Thist works:
flash(u"Proveedor %s añadido." % name)
This doesn't work (because of the ñ)
flash("Proveedor %s añadido." % name)

The following works as long as the name doesn't contain any accents:
def add(self, name):
provider = model.Provider(name=name)

How do I get this working for the whole character set including é, è,
ñ, etc.?

mar...@sismografo.es

unread,
Jul 3, 2007, 7:45:23 AM7/3/07
to TurboGears
I've got it:

name=name.encode('UTF-8')

Milton Galo Patricio Inostroza Aguilera

unread,
Jul 3, 2007, 1:45:20 PM7/3/07
to turbo...@googlegroups.com
in the model you must use UnicodeCol and not StringCol

2007/7/3, mar...@sismografo.es <mar...@sismografo.es>:


--
Milton Inostroza Aguilera

Reply all
Reply to author
Forward
0 new messages