Skip to content

Instantly share code, notes, and snippets.

@shesek
Created February 27, 2012 11:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shesek/1923150 to your computer and use it in GitHub Desktop.
Save shesek/1923150 to your computer and use it in GitHub Desktop.
Default columns for Trac query
# Adds a new `default_cols` option under [query] with a comma-separated list of default columns
# See http://trac-hacks.org/wiki/DefaultColsPlugin
from trac.core import *
from trac.web.main import IRequestFilter
from trac.config import ListOption
class DefaultCols(Component):
implements(IRequestFilter)
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
Copy link
Author

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