本文整理汇总了Python中MoinMoin.Page.Page.getSubscribers方法的典型用法代码示例。如果您正苦于以下问题:Python Page.getSubscribers方法的具体用法?Python Page.getSubscribers怎么用?Python Page.getSubscribers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MoinMoin.Page.Page
的用法示例。
在下文中一共展示了Page.getSubscribers方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle_file_attached
# 需要导入模块: from MoinMoin.Page import Page [as 别名]
# 或者: from MoinMoin.Page.Page import getSubscribers [as 别名]
def handle_file_attached(event):
"""Handles event sent when a file is attached to a page"""
names = set()
request = event.request
page = Page(request, event.pagename)
subscribers = page.getSubscribers(request, return_users=1)
notification.filter_subscriber_list(event, subscribers, True)
recipients = []
for lang in subscribers:
recipients.extend(subscribers[lang])
attachlink = request.getQualifiedURL(getAttachUrl(event.pagename, event.filename, request))
pagelink = request.getQualifiedURL(page.url(request, {}))
for lang in subscribers.keys():
_ = lambda text: request.getText(text, lang=lang)
data = notification.attachment_added(request, _, event.pagename, event.filename, event.size)
links = [{'url': attachlink, 'description': _("Attachment link")},
{'url': pagelink, 'description': _("Page link")}]
jids = [usr.jid for usr in subscribers[lang]]
data['url_list'] = links
data['action'] = "file_attached"
if send_notification(request, jids, data):
names.update(recipients)
return notification.Success(names)
示例2: handle_file_attached
# 需要导入模块: from MoinMoin.Page import Page [as 别名]
# 或者: from MoinMoin.Page.Page import getSubscribers [as 别名]
def handle_file_attached(event):
"""Sends an email to super users that have subscribed to this event type"""
names = set()
from_address = event.request.cfg.mail_from
request = event.request
page = Page(request, event.pagename)
subscribers = page.getSubscribers(request, return_users=1)
notification.filter_subscriber_list(event, subscribers, False)
recipients = []
for lang in subscribers:
recipients.extend(subscribers[lang])
attachlink = request.getBaseURL() + getAttachUrl(event.pagename, event.filename, request)
pagelink = request.getQualifiedURL(page.url(request, {}))
for lang in subscribers:
emails = []
_ = lambda text: request.getText(text, lang=lang)
links = _("Attachment link: %(attach)s\n" \
"Page link: %(page)s\n") % {'attach': attachlink, 'page': pagelink}
data = notification.attachment_added(request, _, event.pagename, event.filename, event.size)
data['text'] = data['text'] + links
emails = [usr.email for usr in subscribers[lang]]
if send_notification(request, from_address, emails, data):
names.update(recipients)
return notification.Success(names)
示例3: notify_subscribers
# 需要导入模块: from MoinMoin.Page import Page [as 别名]
# 或者: from MoinMoin.Page.Page import getSubscribers [as 别名]
def notify_subscribers(macro, comment):
'''Notify page subscribers'''
subscribed_notify = get_cfg(macro, 'comment_subscribed_notify', False)
if not subscribed_notify:
return
request = macro.request
_ = macro.request.getText
page = Page(request, comment['page'])
subscribers = page.getSubscribers(request)
mailing_list = []
for lang in subscribers.keys():
for person in subscribers[lang]:
mailing_list.append(person)
if mailing_list:
sendmail.sendmail( request, mailing_list,
_('New comment was posted in page %(page)s' % comment),
_('New comment was posted in page:\n\nPage: %(page)s\nFrom: %(user_name)s\nMessage:\n\n%(comment)s\n\n--' %
comment ))