本文整理汇总了Python中trac.ticket.Ticket.get_value_or_default方法的典型用法代码示例。如果您正苦于以下问题:Python Ticket.get_value_or_default方法的具体用法?Python Ticket.get_value_or_default怎么用?Python Ticket.get_value_or_default使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trac.ticket.Ticket
的用法示例。
在下文中一共展示了Ticket.get_value_or_default方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: invoke
# 需要导入模块: from trac.ticket import Ticket [as 别名]
# 或者: from trac.ticket.Ticket import get_value_or_default [as 别名]
def invoke(self, message, warnings):
"""make a new ticket on receiving email"""
# local warnings
_warnings = []
# get the ticket reporter
reporter = self._reporter(message)
# get the description and attachments
mailBody, attachments = get_body_and_attachments(message)
mailBody += '\n'
# get the ticket fields
fields = self._fields(mailBody, _warnings, reporter=reporter)
# inset items from email
ticket = Ticket(self.env)
for key, value in fields.items():
ticket.values[key] = value
# fill in default values
for field in ticket.fields:
name = field['name']
if name not in fields:
option = 'ticket_field.%s' % name
if self.env.config.has_option('mail', option):
ticket.values[name] = self.env.config.get('mail', option)
else:
try:
value = ticket.get_value_or_default(name) or ''
except AttributeError: # BBB
value = ''
if value is not None:
ticket.values[name] = value
# create the ticket
ticket.insert()
# add attachments to the ticket
add_attachments(self.env, ticket, attachments)
# do whatever post-processing is necessary
self.post_process(ticket)
# add local warnings
if _warnings:
warning = """A ticket has been created but there is a problem:\n\n%s\n\nPlease edit your ticket by going here: %s""" % ('\n\n'.join([' - %s' % warning for warning in _warnings]), self.env.abs_href('ticket', ticket.id))
warnings.append(warning)