本文整理汇总了Python中trac.ticket.Ticket.values方法的典型用法代码示例。如果您正苦于以下问题:Python Ticket.values方法的具体用法?Python Ticket.values怎么用?Python Ticket.values使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trac.ticket.Ticket
的用法示例。
在下文中一共展示了Ticket.values方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: move
# 需要导入模块: from trac.ticket import Ticket [as 别名]
# 或者: from trac.ticket.Ticket import values [as 别名]
def move(self, ticket_id, author, env, delete=False):
"""
move a ticket to another environment
env: environment to move to
"""
tables = {"attachment": "id", "ticket_change": "ticket"}
# open the environment if it is a string
if isinstance(env, basestring):
base_path, _project = os.path.split(self.env.path)
env = open_environment(os.path.join(base_path, env), use_cache=True)
# get the old ticket
old_ticket = Ticket(self.env, ticket_id)
# make a new ticket from the old ticket values
new_ticket = Ticket(env)
new_ticket.values = old_ticket.values.copy()
new_ticket.insert(when=old_ticket.time_created)
# copy the changelog and attachment DBs
for table, _id in tables.items():
for row in get_all_dict(self.env, "SELECT * FROM %s WHERE %s=%%s" % (table, _id), str(ticket_id)):
row[_id] = new_ticket.id
insert_row_from_dict(env, table, row)
# copy the attachments
src_attachment_dir = os.path.join(self.env.path, "attachments", "ticket", str(ticket_id))
if os.path.exists(src_attachment_dir):
dest_attachment_dir = os.path.join(env.path, "attachments", "ticket")
if not os.path.exists(dest_attachment_dir):
os.makedirs(dest_attachment_dir)
dest_attachment_dir = os.path.join(dest_attachment_dir, str(new_ticket.id))
shutil.copytree(src_attachment_dir, dest_attachment_dir)
# note the previous location on the new ticket
new_ticket.save_changes(author, "moved from %s" % self.env.abs_href("ticket", ticket_id))
# location of new ticket
new_location = env.abs_href.ticket(new_ticket.id)
if delete:
old_ticket.delete()
else:
# close old ticket and point to new one
old_ticket["status"] = u"closed"
old_ticket["resolution"] = u"moved"
old_ticket.save_changes(author, u"moved to %s" % new_location)
if env.config["trac"].get("base_url"):
return new_location
else:
return None
示例2: __create_new_ticket
# 需要导入模块: from trac.ticket import Ticket [as 别名]
# 或者: from trac.ticket.Ticket import values [as 别名]
def __create_new_ticket(self, page, title, owner):
matched = re.compile(r'^\[(.*)\](.*)').search(title)
if matched:
summary = matched.group(2)
owner = matched.group(1)
else:
summary = title
owner = None
ticket = Ticket(self.env)
ticket.values = {
'status': 'new',
'reporter': page.author,
'summary': summary,
'owner': owner,
'description': "wiki:%s" % page.name,
}
return ticket.insert()