Created
February 27, 2012 11:27
-
-
Save shesek/1923150 to your computer and use it in GitHub Desktop.
Default columns for Trac query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There's work in progress at #10425 to get this functionality into core, but in the meanwhile you can use this plugin.