本文整理汇总了Python中trac.mimeview.api.Mimeview.send_converted方法的典型用法代码示例。如果您正苦于以下问题:Python Mimeview.send_converted方法的具体用法?Python Mimeview.send_converted怎么用?Python Mimeview.send_converted使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trac.mimeview.api.Mimeview
的用法示例。
在下文中一共展示了Mimeview.send_converted方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: process_request
# 需要导入模块: from trac.mimeview.api import Mimeview [as 别名]
# 或者: from trac.mimeview.api.Mimeview import send_converted [as 别名]
def process_request(self, req):
req.perm.assert_permission('TICKET_VIEW')
action = req.args.get('action', 'view')
db = self.env.get_db_cnx()
id = int(req.args.get('id'))
ticket = Ticket(self.env, id, db=db)
if req.method == 'POST':
if not req.args.has_key('preview'):
self._do_save(req, db, ticket)
else:
# Use user supplied values
ticket.populate(req.args)
self._validate_ticket(req, ticket)
req.hdf['ticket.action'] = action
req.hdf['ticket.ts'] = req.args.get('ts')
req.hdf['ticket.reassign_owner'] = req.args.get('reassign_owner') \
or req.authname
req.hdf['ticket.resolve_resolution'] = req.args.get('resolve_resolution')
comment = req.args.get('comment')
if comment:
req.hdf['ticket.comment'] = comment
# Wiki format a preview of comment
req.hdf['ticket.comment_preview'] = wiki_to_html(
comment, self.env, req, db)
else:
req.hdf['ticket.reassign_owner'] = req.authname
# Store a timestamp in order to detect "mid air collisions"
req.hdf['ticket.ts'] = ticket.time_changed
self._insert_ticket_data(req, db, ticket,
get_reporter_id(req, 'author'))
mime = Mimeview(self.env)
format = req.args.get('format')
if format:
mime.send_converted(req, 'trac.ticket.Ticket', ticket, format,
'ticket_%d' % ticket.id)
# If the ticket is being shown in the context of a query, add
# links to help navigate in the query result set
if 'query_tickets' in req.session:
tickets = req.session['query_tickets'].split()
if str(id) in tickets:
idx = tickets.index(str(ticket.id))
if idx > 0:
add_link(req, 'first', req.href.ticket(tickets[0]),
u'Ticket #%s' % tickets[0])
add_link(req, 'prev', req.href.ticket(tickets[idx - 1]),
u'Ticket #%s' % tickets[idx - 1])
if idx < len(tickets) - 1:
add_link(req, 'next', req.href.ticket(tickets[idx + 1]),
u'Ticket #%s' % tickets[idx + 1])
add_link(req, 'last', req.href.ticket(tickets[-1]),
u'Ticket #%s' % tickets[-1])
add_link(req, 'up', req.session['query_href'])
add_stylesheet(req, 'common/css/ticket.css')
# Add registered converters
for conversion in mime.get_supported_conversions('trac.ticket.Ticket'):
conversion_href = req.href.ticket(ticket.id, format=conversion[0])
add_link(req, 'alternate', conversion_href, conversion[1],
conversion[3])
return 'ticket.cs', None