ContentRules, Mail Notification - encoding error

2 Messages Forum Options Options
Embed this topic
Permalink
Luis Miguel Braga
ContentRules, Mail Notification - encoding error
Reply Threaded MoreMore options
Print post
Permalink
Hi,

when I was trying to use a content rule to send emails notifications on
workflow state changes I got an encoding error.

......
Module plone.app.contentrules.handlers, line 97, in execute
Module plone.contentrules.engine.executor, line 27, in __call__
Module plone.contentrules.rule.rule, line 48, in __call__
Module plone.app.contentrules.actions.mail, line 94, in __call__
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1:
ordinal not in range(128)


It only happened when the title of the object had special characters.
For example:
If the title was "Pós-Graduado" I'd get the error.
If I changed the title to "Pos-Graduado", the notification would work fine.

I when messing around  in plone.app.contentrules and fixed the problem
by replacing
        event_title = obj.Title()
with
        event_title = obj.Title().decode('utf-8')


I'm not sure that this is the correct way to address this issue.
What do you guys suggest?


lmb

[lmb.vcf]

begin:vcard
fn;quoted-printable:Lu=C3=ADs Miguel Braga
n;quoted-printable:Braga;Lu=C3=ADs Miguel
org;quoted-printable:Eurotux Inform=C3=A1tica SA;UDP
email;internet:lmb@...
note;quoted-printable:msn: lmb@...=0D=0A=
        icq: 468891396
x-mozilla-html:FALSE
version:2.1
end:vcard




-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Plone-developers mailing list
Plone-developers@...
https://lists.sourceforge.net/lists/listinfo/plone-developers

signature.asc (268 bytes) Download Attachment
J M Cerqueira Esteves
Re: ContentRules, Mail Notification - encoding error
Reply Threaded MoreMore options
Print post
Permalink
Luis Miguel Braga wrote:

> UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1:
> ordinal not in range(128)
>
>
> It only happened when the title of the object had special characters.
> For example:
> If the title was "Pós-Graduado" I'd get the error.
> If I changed the title to "Pos-Graduado", the notification would work fine.
>
> I when messing around  in plone.app.contentrules and fixed the problem
> by replacing
>        event_title = obj.Title()
> with
>        event_title = obj.Title().decode('utf-8')
>
>
> I'm not sure that this is the correct way to address this issue.
> What do you guys suggest?

For a long time I've systematically defined Python's default encoding to
be 'utf-8' in machines running Plone, to prevent such issues.   In
Debian Etch systems, I simply edit the definition of setencoding () in
/etc/python2.4/site.py, making
   encoding = "utf-8"
(used a few lines down, in the same function, in a call to
sys,setdefaultencoding () ).

Right now I can't remember if default-zpublisher-encoding,
from the zope.conf file, would also have some effect there (although I
also set it to 'utf-8'...).

Best regards
                     J Esteves


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Plone-developers mailing list
Plone-developers@...
https://lists.sourceforge.net/lists/listinfo/plone-developers