1 ## Script (Python) "after_reject"
2 ##bind container=container
6 ##bind subpath=traverse_subpath
10 from Products
.CMFCore
.utils
import getToolByName
11 mtool
= getToolByName(context
, 'portal_membership')
12 portal
= context
.portal_url
.getPortalObject()
13 MailHost
= portal
.MailHost
14 from quopri
import encodestring
16 def encodeAdr(member
) :
17 name
= member
.getMemberFullName(nameBefore
=0)
18 email
= member
.getProperty('email')
19 qpName
= encodestring(name
).replace('=\n', '')
20 return '''"=?utf-8?q?%s?=" <%s>''' % (qpName
, email
)
25 sender
= mtool
.getAuthenticatedMember()
26 sender
= encodeAdr(sender
)
27 mto
= encodeAdr(member
)
29 subject
= sci
.kwargs
.get('subject', '').strip()
30 body
= sci
.kwargs
.get('body', '').strip()
32 if not (subject
and body
) :
33 raise ValueError, "You must send a consitent email to reject the membership request."
35 mtool
.removeMembers(memberIds
= [member
.getId()])
37 message
= context
.echange_mail_template( From
= sender
39 , Subject
= "=?utf-8?q?%s?=" % encodestring(subject
).replace('=\n', '')
40 , ContentType
= 'text/plain'
45 MailHost
.send( message
.encode('utf-8') )