cannot concatenate 'str' and 'Field' objects
File: db.py
auth.messages.reset_password = 'Hey ' + db.auth_user.username + ' click on the link http://'+request.env.http_host+URL('default','user',args=['reset_password'])+'/%(key)s to reset your password'
auth.messages.reset_password = 'Hey ' + db.auth_user.username + ' click on the link ...'
auth.messages.reset_password = 'Hey ' + auth.user.username + ' Click on the link http://' + request.env.http_host+URL('default','user',args=['reset_password'])+'/%(key)s to reset your password'
<type 'exceptions.AttributeError'>('NoneType' object has no attribute 'username')
to keep testing this.
mail.settings.server = 'logging'
def set_reset_message(form):
user = db.auth_user(email=form.vars.email)
username = user.username if user else ''
auth.messages.reset_password = 'Hey %s, click on the link %%(link)s to reset your password' % username
auth.settings.reset_password_onvalidation = set_reset_message
If the string body starts with <html
and ends with </html>
, it will be sent as a HTML email.
mail.settings.server = 'logging'
## - START CUSTOMIZATION FOR CUSTOM RESET Password EMAIL MESSAGES - - - - - - - - - - - - - - - - - - - - - - ##
# build the email message
# the new line for spacing
nl='\n'
ln1= '- - - - - - - - - - - - - - - - - - - \n'
ln2= ' Yoursite.com'
ln3= ' ' + T("Your company's logan.")
ln4= T('PASSWORD RESET')
ln5= T('A request has been submitted to recover a lost password. To reset your password, click on the link:')
ln6= 'http://'+request.env.http_host+URL('default','user',args=['reset_password'])+'/%(key)s'
ln7= T('If you did not specifically request this password change, please disregard this notice.')
ln8= T('Thank you.')
ln9=' ~' + T('Yoursite.com Team')
ln10= ' http://yoursite.com '
# concatenate the email message
msgpass= ln1 + ln2 + nl + ln3 + nl + ln1 + nl + ln4 + nl*2 + ln5 + nl + ln6 + nl*2 + ln7 + nl*2 + ln8 + nl*2 + ln9 + nl + ln10
# first, change the subject from the default
auth.messages.reset_password_subject = T('[yoursite.com] Your password reset')
# concatenate the message from variable
auth.messages.reset_password = msgpass
'''
This will yield
From: sup...@yoursite.com
To: bsm...@gmail.com
Subject: [Yoursite.com] Your password reset
- - - - - - - - - - - - - - - - - - -
Yoursite.com
Your company's slogan.
- - - - - - - - - - - - - - - - - - -
PASSWORD RESET
A request has been submitted to recover a lost password. To reset your password, click on the link:
http://yoursite.com/1370475612-4b0a1881-43df-480d-8920-623a8825f7b4
If you did not specifically request this password change, please disregard this notice.
Thank you.
~Yoursite.com Team
http://yoursite.com
'''
## - END CUSTOMIZATION FOR CUSTOM RESET EMAIL MESSAGES - - - - - - - - - - - - - - - - - - - - - - ##