# HG changeset patch # User Sverre Rabbelier # Date 1235831308 0 # Node ID 656aace0b15fd61286c77ec247b1cc4b2553a6bc # Parent 283046e54c0179a48ecf37a535833ab0ab0d586d Catch mail exceptions and use get_current_user Patch by: Sverre Rabbelier diff -r 283046e54c01 -r 656aace0b15f app/soc/logic/helper/notifications.py --- a/app/soc/logic/helper/notifications.py Sat Feb 28 13:06:04 2009 +0000 +++ b/app/soc/logic/helper/notifications.py Sat Feb 28 14:28:28 2009 +0000 @@ -224,7 +224,7 @@ # no valid sender found, should not happen but abort anyway return else: - (sender_name, sender) = default_sender + sender_name, sender = default_sender to = accounts.denormalizeAccount(user_entity.account).email() diff -r 283046e54c01 -r 656aace0b15f app/soc/logic/mail_dispatcher.py --- a/app/soc/logic/mail_dispatcher.py Sat Feb 28 13:06:04 2009 +0000 +++ b/app/soc/logic/mail_dispatcher.py Sat Feb 28 14:28:28 2009 +0000 @@ -67,6 +67,7 @@ from django.template import loader from google.appengine.api import mail +from google.appengine.api import users from soc.logic import dicts @@ -114,8 +115,13 @@ message = mail.EmailMessage(**context) message.check_initialized() - # send the message - message.send() + try: + # send the message + message.send() + except Exception, e: + import logging + logging.info(context) + logging.exception(e) def getDefaultMailSender(): """Returns the sender that currently can be used to send emails. @@ -141,13 +147,14 @@ return (site_entity.site_name, site_entity.noreply_email) # use the email address of the current logged in user - user_entity = user_logic.logic.getForCurrentAccount() + account = users.get_current_user() - if not user_entity: + # we need to retrieve account seperately, as user_logic normalizes it + # and the GAE admin API is case sensitive + user_entity = user_logic.logic.getForAccount(account) + + if not account: logging.warning('Non-Authenticated user triggered getDefaultMailSender') return None - # denormalize the account and retrieve the email - sender = accounts.denormalizeAccount(user_entity.account).email() - - return (user_entity.name, sender) + return (user_entity.name, account.email())