Convert subject and body to unicode before sending mail
Not doing this was raising an exception :
Traceback (most recent call last):
File /base/data/home/apps/e~sacred-bonus-88417/1.384178859090314065/gluon/restricted.py, line 227, in restricted
exec ccode in environment
File /base/data/home/apps/e~sacred-bonus-88417/1.384178859090314065/applications/foundit/controllers/default.py, line 127, in <module>
File /base/data/home/apps/e~sacred-bonus-88417/1.384178859090314065/gluon/globals.py, line 393, in <lambda>
self._caller = lambda f: f()
File /base/data/home/apps/e~sacred-bonus-88417/1.384178859090314065/applications/foundit/controllers/default.py, line 34, in user
return dict(form=auth())
File /base/data/home/apps/e~sacred-bonus-88417/1.384178859090314065/gluon/tools.py, line 1595, in __call__
return getattr(self, args[0])()
File /base/data/home/apps/e~sacred-bonus-88417/1.384178859090314065/gluon/tools.py, line 3272, in request_reset_password
if self.email_reset_password(user):
File /base/data/home/apps/e~sacred-bonus-88417/1.384178859090314065/gluon/tools.py, line 3296, in email_reset_password
message=self.messages.reset_password % d):
File /base/data/home/apps/e~sacred-bonus-88417/1.384178859090314065/gluon/tools.py, line 798, in send
subject=subject, body=text, **xcc)
File /base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/mail.py, line 402, in send_mail
message.send(make_sync_call=make_sync_call)
File /base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/mail.py, line 1108, in send
message = self.ToProto()
File /base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/mail.py, line 1350, in ToProto
message = super(EmailMessage, self).ToProto()
File /base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/mail.py, line 1046, in ToProto
message.set_subject(_to_str(self.subject))
File cpp_message.pyx, line 124, in cpp_message.SetScalarAccessors.Setter (third_party/apphosting/python/protobuf/proto1/cpp_message.cc:2229)
TypeError: <class 'gluon.languages.lazyT'> has type <class 'gluon.languages.lazyT'>, but expected one of: str, unicode
This commit is contained in:
@@ -767,8 +767,8 @@ class Mail(object):
|
||||
if self.settings.server == 'logging':
|
||||
logger.warn('email not sent\n%s\nFrom: %s\nTo: %s\nSubject: %s\n\n%s\n%s\n' %
|
||||
('-' * 40, sender,
|
||||
', '.join(to), subject,
|
||||
text or html, '-' * 40))
|
||||
', '.join(to), subject,
|
||||
text or html, '-' * 40))
|
||||
elif self.settings.server == 'gae':
|
||||
xcc = dict()
|
||||
if cc:
|
||||
@@ -779,23 +779,23 @@ class Mail(object):
|
||||
xcc['reply_to'] = reply_to
|
||||
from google.appengine.api import mail
|
||||
attachments = attachments and [mail.Attachment(
|
||||
a.my_filename,
|
||||
a.my_filename,
|
||||
a.my_payload,
|
||||
contebt_id='<attachment-%s>' % k
|
||||
) for k,a in enumerate(attachments) if not raw]
|
||||
if attachments:
|
||||
result = mail.send_mail(
|
||||
sender=sender, to=origTo,
|
||||
subject=subject, body=text, html=html,
|
||||
subject=unicode(subject), body=unicode(text), html=html,
|
||||
attachments=attachments, **xcc)
|
||||
elif html and (not raw):
|
||||
result = mail.send_mail(
|
||||
sender=sender, to=origTo,
|
||||
subject=subject, body=text, html=html, **xcc)
|
||||
subject=unicode(subject), body=unicode(text), html=html, **xcc)
|
||||
else:
|
||||
result = mail.send_mail(
|
||||
sender=sender, to=origTo,
|
||||
subject=subject, body=text, **xcc)
|
||||
subject=unicode(subject), body=unicode(text), **xcc)
|
||||
else:
|
||||
smtp_args = self.settings.server.split(':')
|
||||
kwargs = dict(timeout=self.settings.timeout)
|
||||
@@ -3714,7 +3714,7 @@ class Auth(object):
|
||||
return record.id
|
||||
else:
|
||||
id = membership.insert(group_id=group_id, user_id=user_id)
|
||||
if role:
|
||||
if role:
|
||||
self.user_groups[group_id] = role
|
||||
else:
|
||||
self.update_groups()
|
||||
|
||||
Reference in New Issue
Block a user