Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Default columns for Trac query
# Adds a new `default_cols` option under [query] with a comma-separated list of default columns
# See
from trac.core import *
from trac.web.main import IRequestFilter
from trac.config import ListOption
class DefaultCols(Component):
default_cols = ListOption('query', 'default_cols', default=None,
doc="""List of columns to show in query unless defined by the query.""")
# -- IRequestFilter
def pre_process_request(self, req, handler):
if self.default_cols != None and req.path_info == '/query' and 'col' not in req.args:
req.args['col'] = self.default_cols
return handler
def post_process_request(self, req, template, data, content_type):
return template, data, content_type

shesek commented Feb 27, 2012

There's work in progress at #10425 to get this functionality into core, but in the meanwhile you can use this plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment