#1187: Logging problems with PostgreSQL
--------------------------------+-------------------------------------------
 Reporter:  cito                |       Owner:  somebody
     Type:  defect              |      Status:  new     
 Priority:  major               |   Milestone:  0.8.3   
Component:  db                  |     Version:  0.8.4   
 Keywords:  postgresql logging  |  
--------------------------------+-------------------------------------------
 In dCursorMixin, there is code like the following,
 {{{
 dabo.dbActivityLog.write(_("DBQueryException encountered in save(): %s") %
 e)
 }}}
 where `e` is a `DBQueryException` which in turn has an `err_desc`
 attribute and a `sql` attribute.

 The `_(...)` expression and `e.sql` are unicode, but `e.err_descr` is a
 string containing non-ascii chars encoded as `utf-8` when I'm running dabo
 with PostgreSQL (which is returning German error messages on my system).

 This causes errors in two places:
  * a `UnicodeDecodeError` in `dException` when dabo tries to concatenate
 the unicode `e.sql` and the utf-8 `e.err_descr`.
  * a `UnicodeEncodeError` in `lib.logger` when dabo tries to output the
 unicode to sys.stdout without specifying an encoding

 The second issue could be fixed by replacing dabo's logger with the Python
 logging module (see #1075), but the first issue still needs to be fixed.

 I have attached a simple patch that solves both issues and works for me.
 The patch tries to keep everything in unicode, converting to utf-8 only at
 the end when writing to the log stream (this is the recommended way of
 dealing with such issues).

 Note that this silently assumes that database errors are encoded as utf-8
 which may not always be the case - it could also be configured to
 something different in PostgreSQL - but it is still better than failing
 completely.

-- 
Ticket URL: <http://trac.dabodev.com/ticket/1187>
Dabo Trac <http://trac.dabodev.com>
Trac Page for Dabo


_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: http://leafe.com/archives/byMID/[EMAIL PROTECTED]

Reply via email to