Am Sonntag, 5. Oktober 2008 16:11:49 schrieb Ed Leafe:
>
>       I think that the issue is that you are setting the log to a 'dumb'
> device that expects these encoding issues to be taken care of
> somewhere else. Perhaps you could use (untested) something like:
>
> class StdOutEncoder(object):
>       def write(val):
>               try:
>                       sys.stdout.write(val)
>               except UnicodeDecodeError:
>                       sys.stdout.write(val.encode("utf-8")
>
>

Two small typos in this: it must be "def write(self, val):" and the exception 
that has to be handled is a UnicodeEncodeError.

This works too:

app.DatabaseActivityLog = codecs.getwriter("UTF-8")(sys.stdout)

But I think that assumes that DatabaseActivityLog _only_ writes unicode 
objects. Right? I didn't get errors, but might that have been accident?

Still I'm not quite happy that errors in the logging process can stop the 
saving of a perfectly good record.

Thank you,
Sibylle

-- 
Dr. Sibylle Koczian


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

Reply via email to