Back to index

plone3  3.1.7
password_email.py
Go to the documentation of this file.
00001 ##parameters=member=None, password='secret'
00002 ##
00003 from Products.CMFCore.utils import getUtilityByInterfaceName
00004 from Products.CMFCore.utils import getToolByName
00005 from Products.CMFDefault.utils import decode
00006 from Products.CMFDefault.utils import makeEmail
00007 from Products.CMFDefault.utils import Message as _
00008 
00009 atool = getToolByName(script, 'portal_actions')
00010 ptool = getUtilityByInterfaceName('Products.CMFCore.interfaces.IPropertiesTool')
00011 utool = getToolByName(script, 'portal_url')
00012 portal_url = utool()
00013 
00014 
00015 options = {}
00016 options['password'] = password
00017 
00018 headers = {}
00019 headers['Subject'] = _(u'${portal_title}: Membership reminder',
00020                       mapping={'portal_title': decode(ptool.title(), script)})
00021 headers['From'] = '%s <%s>' % (ptool.getProperty('email_from_name'),
00022                                ptool.getProperty('email_from_address'))
00023 headers['To'] = '<%s>' % (member and member.email or 'foo@example.org')
00024 
00025 mtext = context.password_email_template(**decode(options, script))
00026 return makeEmail(mtext, script, headers)