Back to index

plone3  3.1.7
registered_email.py
Go to the documentation of this file.
00001 ##parameters=member=None, password='secret', email='foo@example.org'
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 
00017 options['portal_title'] = ptool.title()
00018 options['portal_description'] = ptool.getProperty('description')
00019 options['portal_url'] = portal_url
00020 
00021 member_id = member and member.getId() or 'foo'
00022 options['member_id'] = member_id
00023 options['password'] = password
00024 
00025 target = atool.getActionInfo('user/login')['url']
00026 options['login_url'] = '%s' % target
00027 
00028 email_from_name = ptool.getProperty('email_from_name')
00029 options['signature'] = email_from_name
00030 
00031 headers = {}
00032 headers['Subject'] = _(u'${portal_title}: Your Membership Information',
00033                       mapping={'portal_title': decode(ptool.title(), script)})
00034 headers['From'] = '%s <%s>' % (email_from_name,
00035                                ptool.getProperty('email_from_address'))
00036 headers['To'] = '<%s>' % email
00037 
00038 mtext = context.registered_email_template(**decode(options, script))
00039 return makeEmail(mtext, script, headers)