本文整理汇总了Python中genshi.template.text.NewTextTemplate.split方法的典型用法代码示例。如果您正苦于以下问题:Python NewTextTemplate.split方法的具体用法?Python NewTextTemplate.split怎么用?Python NewTextTemplate.split使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类genshi.template.text.NewTextTemplate
的用法示例。
在下文中一共展示了NewTextTemplate.split方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: notify
# 需要导入模块: from genshi.template.text import NewTextTemplate [as 别名]
# 或者: from genshi.template.text.NewTextTemplate import split [as 别名]
def notify(self, req, ticket, name):
ctx = self.build_template_context(req, ticket, name)
section = self.config['ticket-workflow-notifications']
condition = section.get('%s.condition' % name, None)
if condition is not None:
condition_value = TextTemplate(condition.replace("\\n", "\n")
).generate(**ctx).render(encoding=None).strip()
if condition_value != 'True':
self.log.debug("Skipping notification %s for ticket %s "
"because condition '%s' did not evaluate to True (it evaluated to %s)" % (
name, ticket.id if ticket.exists else "(new ticket)",
condition, condition_value))
return False
else:
self.log.debug("Sending notification %s for ticket %s "
"because condition '%s' did evaluate to True" % (
name, ticket.id if ticket.exists else "(new ticket)", condition))
else:
self.log.debug("Sending notification %s for ticket %s "
"because there was no condition" % (
name, ticket.id if ticket.exists else "(new ticket)"))
body = TextTemplate(section.get('%s.body' % name).replace("\\n", "\n")
).generate(**ctx).render(encoding=None)
subject = TextTemplate(section.get('%s.subject' % name).replace("\\n", "\n")
).generate(**ctx).render(encoding=None)
subject = ' '.join(subject.splitlines())
recipients = TextTemplate(section.get('%s.recipients' % name).replace("\\n", "\n")
).generate(**ctx).render(encoding=None)
recipients = [r.strip() for r in recipients.split(",")]
notifier = WorkflowNotifyEmail(
self.env, template_name='ticket_notify_workflow_email.txt',
recipients=recipients, data={'body': body})
vars = inspect.getargspec(notifier.notify)[0]
if len(vars) == 3: # Trac 0.12 and below
args = [ticket.id, subject]
elif len(vars) == 4: # Trac 0.13 and up have an additional `author` argument to trac.notification:NotifyEmail.notify
args = [ticket.id, subject, req.authname]
else:
self.log.error("Cannot send notification %s for ticket %s "
"because this trac version has an unknown NotifyEmail.notify signature "
"%s" % (name, ticket.id if ticket.exists else "(new ticket)", condition,
vars))
return False
notifier.notify(*args)