本文整理汇总了Python中Mailman.Utils.maketext方法的典型用法代码示例。如果您正苦于以下问题:Python Utils.maketext方法的具体用法?Python Utils.maketext怎么用?Python Utils.maketext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mailman.Utils
的用法示例。
在下文中一共展示了Utils.maketext方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: loginpage
# 需要导入模块: from Mailman import Utils [as 别名]
# 或者: from Mailman.Utils import maketext [as 别名]
def loginpage(mlist, scriptname, msg='', frontpage=None):
url = mlist.GetScriptURL(scriptname)
if frontpage:
actionurl = url
else:
actionurl = Utils.GetRequestURI(url)
if msg:
msg = FontAttr(msg, color='#ff0000', size='+1').Format()
# give an HTTP 401 for authentication failure
print 'Status: 401 Unauthorized'
if scriptname == 'admindb':
who = _('Moderator')
else:
who = _('Administrator')
# Language stuff
charset = Utils.GetCharSet(mlist.preferred_language)
print 'Content-type: text/html; charset=' + charset + '\n\n'
print Utils.maketext(
'admlogin.html',
{'listname': mlist.real_name,
'path' : actionurl,
'message' : msg,
'who' : who,
}, mlist=mlist)
print mlist.GetMailmanFooter()
示例2: __sendAdminBounceNotice
# 需要导入模块: from Mailman import Utils [as 别名]
# 或者: from Mailman.Utils import maketext [as 别名]
def __sendAdminBounceNotice(self, member, msg):
# BAW: This is a bit kludgey, but we're not providing as much
# information in the new admin bounce notices as we used to (some of
# it was of dubious value). However, we'll provide empty, strange, or
# meaningless strings for the unused %()s fields so that the language
# translators don't have to provide new templates.
siteowner = Utils.get_site_email(self.host_name)
text = Utils.maketext(
"bounce.txt",
{
"listname": self.real_name,
"addr": member,
"negative": "",
"did": _("disabled"),
"but": "",
"reenable": "",
"owneraddr": siteowner,
},
mlist=self,
)
subject = _("Bounce action notification")
umsg = Message.UserNotification(self.GetOwnerEmail(), siteowner, subject, lang=self.preferred_language)
# BAW: Be sure you set the type before trying to attach, or you'll get
# a MultipartConversionError.
umsg.set_type("multipart/mixed")
umsg.attach(MIMEText(text, _charset=Utils.GetCharSet(self.preferred_language)))
if isinstance(msg, StringType):
umsg.attach(MIMEText(msg))
else:
umsg.attach(MIMEMessage(msg))
umsg.send(self)
示例3: ParseTags
# 需要导入模块: from Mailman import Utils [as 别名]
# 或者: from Mailman.Utils import maketext [as 别名]
def ParseTags(self, template, replacements, lang=None):
if lang is None:
charset = 'us-ascii'
else:
charset = Utils.GetCharSet(lang)
text = Utils.maketext(template, raw=1, lang=lang, mlist=self)
parts = re.split('(</?[Mm][Mm]-[^>]*>)', text)
i = 1
while i < len(parts):
tag = parts[i].lower()
if replacements.has_key(tag):
repl = replacements[tag]
if isinstance(repl, type(u'')):
repl = repl.encode(charset, 'replace')
parts[i] = repl
else:
parts[i] = ''
# EGL: Munged these values to handle the separate hostnames for the
# mail and web servers.
if tag == "<mm-posting-addr>":
parts[i] = parts[i].replace("mail.", "")
i = i + 2
return EMPTYSTRING.join(parts)
示例4: process
# 需要导入模块: from Mailman import Utils [as 别名]
# 或者: from Mailman.Utils import maketext [as 别名]
def process(mlist, msg, msgdata):
# Extract the sender's address and find them in the user database
sender = msgdata.get('original_sender', msg.get_sender())
try:
ack = mlist.getMemberOption(sender, mm_cfg.AcknowledgePosts)
if not ack:
return
except Errors.NotAMemberError:
return
# Okay, they want acknowledgement of their post. Give them their original
# subject. BAW: do we want to use the decoded header?
origsubj = msgdata.get('origsubj', msg.get('subject', _('(no subject)')))
# Get the user's preferred language
lang = msgdata.get('lang', mlist.getMemberLanguage(sender))
# Now get the acknowledgement template
realname = mlist.real_name
text = Utils.maketext(
'postack.txt',
{'subject' : Utils.oneline(origsubj, Utils.GetCharSet(lang)),
'listname' : realname,
'listinfo_url': mlist.GetScriptURL('listinfo', absolute=1),
'optionsurl' : mlist.GetOptionsURL(sender, absolute=1),
}, lang=lang, mlist=mlist, raw=1)
# Craft the outgoing message, with all headers and attributes
# necessary for general delivery. Then enqueue it to the outgoing
# queue.
subject = _('%(realname)s post acknowledgement')
usermsg = Message.UserNotification(sender, mlist.GetBouncesEmail(),
subject, text, lang)
usermsg.send(mlist)
示例5: sendProbe
# 需要导入模块: from Mailman import Utils [as 别名]
# 或者: from Mailman.Utils import maketext [as 别名]
def sendProbe(self, member, msg):
listname = self.real_name
# Put together the substitution dictionary.
d = {
"listname": listname,
"address": member,
"optionsurl": self.GetOptionsURL(member, absolute=True),
"owneraddr": self.GetOwnerEmail(),
}
text = Utils.maketext("probe.txt", d, lang=self.getMemberLanguage(member), mlist=self)
# Calculate the VERP'd sender address for bounce processing of the
# probe message.
token = self.pend_new(Pending.PROBE_BOUNCE, member, msg)
probedict = {"bounces": self.internal_name() + "-bounces", "token": token}
probeaddr = "%[email protected]%s" % ((mm_cfg.VERP_PROBE_FORMAT % probedict), self.host_name)
# Calculate the Subject header, in the member's preferred language
ulang = self.getMemberLanguage(member)
otrans = i18n.get_translation()
i18n.set_language(ulang)
try:
subject = _("%(listname)s mailing list probe message")
finally:
i18n.set_translation(otrans)
outer = Message.UserNotification(member, probeaddr, subject, lang=ulang)
outer.set_type("multipart/mixed")
text = MIMEText(text, _charset=Utils.GetCharSet(ulang))
outer.attach(text)
outer.attach(MIMEMessage(msg))
# Turn off further VERP'ing in the final delivery step. We set
# probe_token for the OutgoingRunner to more easily handling local
# rejects of probe messages.
outer.send(self, envsender=probeaddr, verp=False, probe_token=token)
示例6: __refuse
# 需要导入模块: from Mailman import Utils [as 别名]
# 或者: from Mailman.Utils import maketext [as 别名]
def __refuse(self, request, recip, comment, origmsg=None, lang=None):
# As this message is going to the requestor, try to set the language
# to his/her language choice, if they are a member. Otherwise use the
# list's preferred language.
realname = self.real_name
if lang is None:
lang = self.getMemberLanguage(recip)
text = Utils.maketext(
'refuse.txt',
{'listname' : realname,
'request' : request,
'reason' : comment,
'adminaddr': self.GetOwnerEmail(),
}, lang=lang, mlist=self)
otrans = i18n.get_translation()
i18n.set_language(lang)
try:
# add in original message, but not wrap/filled
if origmsg:
text = NL.join(
[text,
'---------- ' + _('Original Message') + ' ----------',
str(origmsg)
])
subject = _('Request to mailing list %(realname)s rejected')
finally:
i18n.set_translation(otrans)
msg = Message.UserNotification(recip, self.GetOwnerEmail(),
subject, text, lang)
msg.send(self)
示例7: HoldUnsubscription
# 需要导入模块: from Mailman import Utils [as 别名]
# 或者: from Mailman.Utils import maketext [as 别名]
def HoldUnsubscription(self, addr):
# Assure the database is open for writing
self.__opendb()
# Get the next unique id
id = self.__nextid()
# All we need to do is save the unsubscribing address
self.__db[id] = (UNSUBSCRIPTION, addr)
syslog('vette', '%s: held unsubscription request from %s',
self.internal_name(), addr)
# Possibly notify the administrator of the hold
if self.admin_immed_notify:
realname = self.real_name
subject = _(
'New unsubscription request from %(realname)s by %(addr)s')
text = Utils.maketext(
'unsubauth.txt',
{'username' : addr,
## cpanel patch
'listname' : self.real_name,
'hostname' : self.host_name,
'admindb_url': self.GetScriptURL('admindb', absolute=1),
}, mlist=self)
# This message should appear to come from the <list>-owner so as
# to avoid any useless bounce processing.
owneraddr = self.GetOwnerEmail()
msg = Message.UserNotification(owneraddr, owneraddr, subject, text,
self.preferred_language)
msg.send(self, **{'tomoderators': 1})
示例8: create
# 需要导入模块: from Mailman import Utils [as 别名]
# 或者: from Mailman.Utils import maketext [as 别名]
def create(self, email):
if self.exists:
raise ListAlreadyExists
langs = [mm_cfg.DEFAULT_SERVER_LANGUAGE]
pw = Utils.MakeRandomPassword()
pw_hashed = Utils.sha_new(pw).hexdigest()
urlhost = mm_cfg.DEFAULT_URL_HOST
host_name = mm_cfg.DEFAULT_EMAIL_HOST
web_page_url = mm_cfg.DEFAULT_URL_PATTERN % urlhost
# TODO: Add some atomicity. We should roll back changes using
# a try/else if something (like MTA alias update) fails
# before the function terminates.
try:
oldmask = os.umask(002)
self.mlist.Create(self.name, email, pw_hashed, langs=langs,
emailhost=host_name, urlhost=urlhost)
self.mlist.preferred_language = langs[0]
# Reply-To set to list address
self.mlist.reply_goes_to_list = 2
self.mlist.reply_to_address = "%[email protected]%s" % (self.list, self.domain)
# Allow messages from [email protected]
self.mlist.acceptable_aliases = "%[email protected]%s\n" % (self.list, self.domain)
self.mlist.subject_prefix = "[%s] " % (self.list)
self.mlist.msg_footer = ""
self.mlist.subscribe_policy = 2 # Confirm and approve
self.mlist.max_message_size = 20480 # 20M
self.mlist.Save()
finally:
os.umask(oldmask)
self.mlist.Unlock()
if mm_cfg.MTA:
modname = 'Mailman.MTA.' + mm_cfg.MTA
__import__(modname)
sys.modules[modname].create(self.mlist)
siteowner = Utils.get_site_email(self.mlist.host_name, 'owner')
text = Utils.maketext(
'newlist.txt',
{'listname' : self.name,
'password' : pw,
'admin_url' : self.mlist.GetScriptURL('admin', absolute=1),
'listinfo_url': self.mlist.GetScriptURL('listinfo', absolute=1),
'requestaddr' : self.mlist.GetRequestEmail(),
'siteowner' : siteowner,
}, mlist=self.mlist)
msg = Message.UserNotification(email, siteowner, 'Your new mailing list: %s' % self.name,
text, self.mlist.preferred_language)
msg.send(self.mlist)
示例9: hold_for_approval
# 需要导入模块: from Mailman import Utils [as 别名]
# 或者: from Mailman.Utils import maketext [as 别名]
def hold_for_approval(mlist, msg, msgdata, exc):
# TBD: This should really be tied into the email confirmation system so
# that the message can be approved or denied via email as well as the
# Web. That's for later though, because it would mean a revamp of the
# MailCommandHandler too.
#
if type(exc) is ClassType:
# Go ahead and instantiate it now.
exc = exc()
listname = mlist.real_name
reason = str(exc)
sender = msg.GetSender()
adminaddr = mlist.GetAdminEmail()
msgdata['rejection-notice'] = exc.rejection_notice(mlist)
mlist.HoldMessage(msg, reason, msgdata)
# now we need to craft and send a message to the list admin so they can
# deal with the held message
d = {'listname' : listname,
'hostname' : mlist.host_name,
'reason' : reason,
'sender' : sender,
'subject' : msg.get('subject', '(no subject)'),
'admindb_url': mlist.GetScriptURL('admindb', absolute=1),
}
if mlist.admin_immed_notify:
# get the text from the template
subject = '%s post from %s requires approval' % (listname, sender)
text = Utils.maketext('postauth.txt', d, raw=1)
# craft the admin notification message and deliver it
msg = Message.UserNotification(adminaddr, adminaddr, subject, text)
HandlerAPI.DeliverToUser(mlist, msg)
# We may want to send a notification to the original sender too
fromusenet = msgdata.get('fromusenet')
if not fromusenet and not mlist.dont_respond_to_post_requests:
subject = 'Your message to %s awaits moderator approval' % listname
text = Utils.maketext('postheld.txt', d)
msg = Message.UserNotification(sender, adminaddr, subject, text)
HandlerAPI.DeliverToUser(mlist, msg)
# Log the held message
syslog('vette', '%s post from %s held: %s' % (listname, sender, reason))
# raise the specific MessageHeld exception to exit out of the message
# delivery pipeline
raise exc
示例10: process
# 需要导入模块: from Mailman import Utils [as 别名]
# 或者: from Mailman.Utils import maketext [as 别名]
def process(res, args):
# Get the help text introduction
mlist = res.mlist
# Since this message is personalized, add some useful information if the
# address requesting help is a member of the list.
msg = res.msg
for sender in msg.get_senders():
if mlist.isMember(sender):
memberurl = mlist.GetOptionsURL(sender, absolute=1)
urlhelp = _(
'You can access your personal options via the following url:')
res.results.append(urlhelp)
res.results.append(memberurl)
# Get a blank line in the output.
res.results.append('')
break
# build the specific command helps from the module docstrings
modhelps = {}
import Mailman.Commands
path = os.path.dirname(os.path.abspath(Mailman.Commands.__file__))
for file in os.listdir(path):
if not file.startswith('cmd_') or not file.endswith('.py'):
continue
module = os.path.splitext(file)[0]
modname = 'Mailman.Commands.' + module
try:
__import__(modname)
except ImportError:
continue
cmdname = module[4:]
help = None
if hasattr(sys.modules[modname], 'gethelp'):
help = sys.modules[modname].gethelp(mlist)
if help:
modhelps[cmdname] = help
# Now sort the command helps
helptext = []
keys = modhelps.keys()
keys.sort()
for cmd in keys:
helptext.append(modhelps[cmd])
commands = EMPTYSTRING.join(helptext)
# Now craft the response
helptext = Utils.maketext(
'help.txt',
{'listname' : mlist.real_name,
'version' : mm_cfg.VERSION,
'listinfo_url': mlist.GetScriptURL('listinfo', absolute=1),
'requestaddr' : mlist.GetRequestEmail(),
'adminaddr' : mlist.GetOwnerEmail(),
'commands' : commands,
}, mlist=mlist, lang=res.msgdata['lang'], raw=1)
# Now add to the response
res.results.append('help')
res.results.append(helptext)
示例11: SendSubscribeAck
# 需要导入模块: from Mailman import Utils [as 别名]
# 或者: from Mailman.Utils import maketext [as 别名]
def SendSubscribeAck(self, name, password, digest, text=""):
pluser = self.getMemberLanguage(name)
# Need to set this here to get the proper l10n of the Subject:
i18n.set_language(pluser)
if self.welcome_msg:
welcome = Utils.wrap(self.welcome_msg) + "\n"
else:
welcome = ""
if self.umbrella_list:
addr = self.GetMemberAdminEmail(name)
umbrella = Utils.wrap(
_(
"""\
Note: Since this is a list of mailing lists, administrative
notices like the password reminder will be sent to
your membership administrative address, %(addr)s."""
)
)
else:
umbrella = ""
# get the text from the template
text += Utils.maketext(
"subscribeack.txt",
{
"real_name": self.real_name,
"host_name": self.host_name,
"welcome": welcome,
"umbrella": umbrella,
"emailaddr": self.GetListEmail(),
"listinfo_url": self.GetScriptURL("listinfo", absolute=True),
"optionsurl": self.GetOptionsURL(name, absolute=True),
"password": password,
"user": self.getMemberCPAddress(name),
},
lang=pluser,
mlist=self,
)
if digest:
digmode = _(" (Digest mode)")
else:
digmode = ""
realname = self.real_name
msg = Message.UserNotification(
self.GetMemberAdminEmail(name),
self.GetRequestEmail(),
_('Welcome to the "%(realname)s" mailing list%(digmode)s'),
text,
pluser,
)
msg["X-No-Archive"] = "yes"
msg.send(self, verp=mm_cfg.VERP_PERSONALIZED_DELIVERIES)
示例12: GetConfigInfo
# 需要导入模块: from Mailman import Utils [as 别名]
# 或者: from Mailman.Utils import maketext [as 别名]
def GetConfigInfo(self):
WIDTH = mm_cfg.TEXTFIELDWIDTH
return [
"Batched-delivery digest characteristics.",
('digestable', mm_cfg.Toggle, ('No', 'Yes'), 1,
'Can list members choose to receive list traffic '
'bunched in digests?'),
('digest_is_default', mm_cfg.Radio,
('Regular', 'Digest'), 0,
'Which delivery mode is the default for new users?'),
('mime_is_default_digest', mm_cfg.Radio,
('Plain', 'Mime'), 0,
'When receiving digests, which format is default?'),
('digest_size_threshhold', mm_cfg.Number, 3, 0,
'How big in Kb should a digest be before it gets sent out?'),
# Should offer a 'set to 0' for no size threshhold.
('digest_send_periodic', mm_cfg.Radio, ('No', 'Yes'), 1,
'Should a digest be dispatched daily when the size threshold '
"isn't reached?"),
('digest_header', mm_cfg.Text, (4, WIDTH), 0,
'Header added to every digest',
"Text attached (as an initial message, before the table"
" of contents) to the top of digests. "
+ Utils.maketext('headfoot.html', raw=1)),
('digest_footer', mm_cfg.Text, (4, WIDTH), 0,
'Footer added to every digest',
"Text attached (as a final message) to the bottom of digests. "
+ Utils.maketext('headfoot.html', raw=1)),
]
示例13: MailUserPassword
# 需要导入模块: from Mailman import Utils [as 别名]
# 或者: from Mailman.Utils import maketext [as 别名]
def MailUserPassword(self, user):
listfullname = "%[email protected]%s" % (self.real_name, self.host_name)
requestaddr = self.GetRequestEmail()
# find the lowercased version of the user's address
adminaddr = self.GetBouncesEmail()
assert self.isMember(user)
if not self.getMemberPassword(user):
# The user's password somehow got corrupted. Generate a new one
# for him, after logging this bogosity.
syslog("error", "User %s had a false password for list %s", user, self.internal_name())
waslocked = self.Locked()
if not waslocked:
self.Lock()
try:
self.setMemberPassword(user, Utils.MakeRandomPassword())
self.Save()
finally:
if not waslocked:
self.Unlock()
# Now send the user his password
cpuser = self.getMemberCPAddress(user)
recipient = self.GetMemberAdminEmail(cpuser)
subject = _("%(listfullname)s mailing list reminder")
# Get user's language and charset
lang = self.getMemberLanguage(user)
cset = Utils.GetCharSet(lang)
password = self.getMemberPassword(user)
# TK: Make unprintables to ?
# The list owner should allow users to set language options if they
# want to use non-us-ascii characters in password and send it back.
password = unicode(password, cset, "replace").encode(cset, "replace")
# get the text from the template
text = Utils.maketext(
"userpass.txt",
{
"user": cpuser,
"listname": self.real_name,
"fqdn_lname": self.GetListEmail(),
"password": password,
"options_url": self.GetOptionsURL(user, absolute=True),
"requestaddr": requestaddr,
"owneraddr": self.GetOwnerEmail(),
},
lang=lang,
mlist=self,
)
msg = Message.UserNotification(recipient, adminaddr, subject, text, lang)
msg["X-No-Archive"] = "yes"
msg.send(self, verp=mm_cfg.VERP_PERSONALIZED_DELIVERIES)
示例14: ParseTag
# 需要导入模块: from Mailman import Utils [as 别名]
# 或者: from Mailman.Utils import maketext [as 别名]
def ParseTag(self, template, replacements):
text = Utils.maketext(template, raw=1, lang=lang, mlist=self)
parts = re.split('(</?[Mm][Mm]-[^>]*>)', text)
i = 1
while i < len(parts):
tag = parts[i].lower()
if replacements.has_key(tag):
repl = replacements[tag]
if isinstance(repl, type(u'')):
repl = repl.encode(charset, 'replace')
parts[i] = repl
else:
parts[i] = ''
i = i + 2
return EMPTYSTRING.join(parts)
示例15: __refuse
# 需要导入模块: from Mailman import Utils [as 别名]
# 或者: from Mailman.Utils import maketext [as 别名]
def __refuse(self, request, recip, comment, origmsg=None):
adminaddr = self.GetAdminEmail()
text = Utils.maketext(
'refuse.txt',
{'listname' : self.real_name,
'request' : request,
'reason' : comment,
'adminaddr': adminaddr,
})
# add in original message, but not wrap/filled
if origmsg:
text = string.join([text,
'---------- Original Message ----------',
str(origmsg)], '\n')
subject = 'Request to mailing list %s rejected' % self.real_name
msg = Message.UserNotification(recip, adminaddr, subject, text)
HandlerAPI.DeliverToUser(self, msg, {'_enqueue_immediate': 1})