#92 — UnicodeDecodeError when sending mail from workflow script

by Radim Novotny last modified Jan 08, 2009 02:59 PM
State Resolved
Version: 2.0
Area Functionality
Issue type Bug
Severity Medium
Submitted by Radim Novotny
Submitted on Oct 17, 2008
Responsible Maurits van Rees
Target release: 2.0
When I assigned user to task and saved form, UnicodeDecodeError was raised.

    * Module Products.Archetypes.BaseObject, line 661, in processForm
    * Module Products.Archetypes.BaseObject, line 651, in _processForm
      __traceback_info__: (<Task at /portal/projekty/ekofaktura/uzivatelske-role-v-systemu/3>, <Field assignees(lines:rw)>, <bound method Task.setAssignees of <Task at /portal/projekty/ekofaktura/uzivatelske-role-v-systemu/3>>)
    * Module Products.Archetypes.utils, line 160, in mapply
    * Module Products.eXtremeManagement.content.Task, line 184, in setAssignees
    * Module Products.eXtremeManagement.Extensions.workflow_scripts, line 98, in mailMessage

UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 12: ordinal not in range(128)

I'v tried to find out what happened and mCreator was unicode and all other variables encoded.
Line: message = mMsg % (obj_url, mCreator, description, estimate, listofAssignees) failed with UnicodeDecodeError.

It would be better to have all values unicode and encode them just before sending to MailHost (MailHost requires values encoded).
Added by Radim Novotny on Oct 17, 2008 02:42 PM
Target release: 2.0None
Responsible manager: maurits(UNASSIGNED)
Attached diff
Added by Maurits van Rees on Nov 20, 2008 03:34 PM
Issue state: unconfirmedresolved
Target release: None2.0
Responsible manager: (UNASSIGNED)maurits
Hi,

Thanks for the report. I think r76173 will fix this on trunk; please check. It's a bigger change than your patch; I'll probably use that patch for the 1.6 branch. The change I did contains a refactoring of the email sending, along the lines of what I did in the plonehrm.notifications package, which takes some good ideas from Marius Gedminas: http://mg.pov.lt/blog/unicode-emails-in-python.html

After this change, emails are only sent when transitioning the task to the 'to-do' state, instead of the Task.setAssignees hack that would send an email whenever the assignees were changed; see issue #124.
Added by Maurits van Rees on Nov 21, 2008 12:45 PM
Radim, I added your patch to the 1.6 branch in r76256. Thanks!

No responses can be added.