Re: [flask] flash a message from trigger
- From:
- sonic steph
- Date:
- 2014-04-27 @ 12:27
In fact, this is an encoding issues. The sqlalchemy connection is
initialized with :
SQLALCHEMY_DATABASE_URI = 'mysql://{}:{}@{}/{}?charset=utf8'.\
format(user,passwd,host,dbName)
logging or flash messages from trigger gives this :
(OperationalError) (1644, 'Il existe d\xc3\xa9j\xc3\xa0 un amapien r\xc3
\xa9pondant au nom ...')
In my first message, I translate into english, which was a bad idea,
caused you can't see this encoding issue.. Even if I,
try:
db.session.commit()
except Exception as e:
flash(u"%s" % e.message)
app.logger.error(unicode(e.message).encode("utf-8"))
db.session.flush()
I can't have a user friendly correct string error message from the
trigger..
cheers
stéphane