Archive for May, 2008

Adding Default Descriptions to Trac Tickets

Friday, May 2nd, 2008

I’ve been using Trac for the new projects I’m working on, and am liking it so far. I have, however, done a bit of customization to make it fit my needs a bit better. One thing that took awhile was figuring out how to change the default ticket description.

I like having some structure to my bug descriptions, including steps to reproduce, regression information, etc. Thankfully, Trac’s template system allows you to replace output with an override template (typically found in templates/site.html) that is applied before content is sent across the wire. It was a bit time-consuming to figure out how to do what I wanted to do, but I eventually ended up with a templates/site.html file that looks something like this:

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://genshi.edgewall.org/" py:strip=""> <!-- Custom match templates go here --> <span py:if="req.environ['PATH_INFO']=='/newticket' and not req.args.has_key('preview')"> <textarea py:match="textarea[@id='field-description' and @class='wikitext']" py:attrs="select('@*')"> Your custom description goes here. </textarea> </span> </html>

I hope this is useful for someone. 🙂