如何在定制trac模板文件时使用当前票号?

我正在尝试自定义trac。 查看门票时,我想在“操作”框中添加一个小的“有用的链接”部分。

我已经编辑了trac模板目录中的site.html文件,如下所示:

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://genshi.edgewall.org/" py:strip=""> <fieldset py:match="fieldset[@id='action']" py:attrs="select('@*')" once="true"> ${select('*|text()')} <div>Useful links: <a href="http://dev.peopleperhour.com/trac/pph/search?q=%231234&amp;noquickjump=1&amp;changeset=on">view all ticket changesets</a></div> </fieldset> </html> 

结果是我有一个方便的链接到search页面,显示票#1234的所有变更集。 伟大的…除了票号(即#1234)目前硬编码,我需要它是dynamic的,即使用当前页面的票号。 我猜可能有一个我可以使用的pythonvariables,或者我可能能够从url获取票号( http://www.example.com/trac/myproject/ticket/1234 )。 任何人都知道我能做到吗?

我需要的variables叫$ticket.id

/var/www/trac/myproject/templates/site.html中的工作代码:

 <html xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://genshi.edgewall.org/" py:strip=""> <fieldset py:match="fieldset[@id='action']" py:attrs="select('@*')" once="true"> ${select('*|text()')} <div>Useful links: <a href="http://dev.peopleperhour.com:8000/projects/1/stages/1/deployments/new?task=deploy">Deploy to Staging</a>, <a href="http://dev.peo\ pleperhour.com/trac/pph/search?q=%23$ticket.id&amp;noquickjump=1&amp;changeset=on">View all changesets for this ticket</a></div> </fieldset> </html>