Don't rely on app_config if common.TESTS_ENABLED.

app_config will be None in this case, so all of these subscripts will
fail.
This commit is contained in:
Brett Smith 2012-07-08 10:37:33 -04:00
parent 4a791b8006
commit 16b8e3afd8

View File

@ -98,8 +98,9 @@ def send_email(from_addr, to_addrs, subject, message_body):
if not mg_globals.app_config['email_smtp_host']: # e.g. host = '' if not mg_globals.app_config['email_smtp_host']: # e.g. host = ''
mhost.connect() # We SMTP.connect explicitly mhost.connect() # We SMTP.connect explicitly
if mg_globals.app_config['email_smtp_user'] \ if ((not common.TESTS_ENABLED)
or mg_globals.app_config['email_smtp_pass']: and (mg_globals.app_config['email_smtp_user']
or mg_globals.app_config['email_smtp_pass'])):
mhost.login( mhost.login(
mg_globals.app_config['email_smtp_user'], mg_globals.app_config['email_smtp_user'],
mg_globals.app_config['email_smtp_pass']) mg_globals.app_config['email_smtp_pass'])
@ -112,7 +113,7 @@ def send_email(from_addr, to_addrs, subject, message_body):
if common.TESTS_ENABLED: if common.TESTS_ENABLED:
EMAIL_TEST_INBOX.append(message) EMAIL_TEST_INBOX.append(message)
if mg_globals.app_config['email_debug_mode']: elif mg_globals.app_config['email_debug_mode']:
print u"===== Email =====" print u"===== Email ====="
print u"From address: %s" % message['From'] print u"From address: %s" % message['From']
print u"To addresses: %s" % message['To'] print u"To addresses: %s" % message['To']