Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adding support for raw (unformatted) output.

  • Loading branch information...
commit 8f4ed4c04fcbdf819ffa84b2ef7e9be92a740507 1 parent cc90046
@mrjbq7 authored
View
7 tracsql/htdocs/common.css
@@ -4,6 +4,13 @@ div.query table {
border: 1px #ccc solid;
}
+div.query input {
+ border: 1px #ccc solid;
+ padding: 3px;
+ font-size: 1.0em;
+ background: #fff;
+}
+
div.query textarea {
border: 1px #ccc solid;
font-family: monospace
View
8 tracsql/templates/sql.html
@@ -25,6 +25,14 @@
<tr><td align="left">
<input type="submit" value="Submit" />&nbsp;
<input type="reset" value="Reset" />&nbsp;
+<py:choose test="raw">
+<py:when>
+<input type="checkbox" name="raw" checked="checked" />Raw Output
+</py:when>
+<py:otherwise>
+<input type="checkbox" name="raw" />Raw Output
+</py:otherwise>
+</py:choose>
</td></tr>
</table>
</form>
View
41 tracsql/web_ui.py
@@ -113,21 +113,7 @@ def _process(self, req, cursor, data):
pass
sql = req.args.get('query', '')
-
- format = {
- 'path' : lambda x: html.A(x, href=req.href.browser(x)),
- 'rev' : lambda x: html.A(x, href=req.href.changeset(x)),
- 'time' : lambda x: fmt_timestamp(x),
- }
-
- if trac.__version__.startswith('0.12'):
- format['time'] = lambda x: fmt_timestamp(x/1000000.)
-
- format['base_path'] = format['path']
- format['base_rev'] = format['rev']
- format['changetime'] = format['time']
-
- default = lambda x: x
+ raw = req.args.get('raw', '')
error = None
@@ -142,15 +128,32 @@ def _process(self, req, cursor, data):
else:
cols = rows = []
- # FIXME: Optionally format the row values? e.g., "raw" output?
- formats = [format.get(col, default) for col in cols]
- for i, row in enumerate(rows):
- rows[i] = [fmt(col) for fmt, col in zip(formats, row)]
+ if not raw:
+
+ format = {
+ 'path' : lambda x: html.A(x, href=req.href.browser(x)),
+ 'rev' : lambda x: html.A(x, href=req.href.changeset(x)),
+ 'time' : lambda x: fmt_timestamp(x),
+ }
+
+ if trac.__version__.startswith('0.12'):
+ format['time'] = lambda x: fmt_timestamp(x/1000000.)
+
+ format['base_path'] = format['path']
+ format['base_rev'] = format['rev']
+ format['changetime'] = format['time']
+
+ default = lambda x: x
+
+ formats = [format.get(col, default) for col in cols]
+ for i, row in enumerate(rows):
+ rows[i] = [fmt(col) for fmt, col in zip(formats, row)]
data['query'] = sql
data['error'] = error
data['cols'] = cols
data['rows'] = rows
+ data['raw'] = raw
return 'sql.html', data, None
Please sign in to comment.
Something went wrong with that request. Please try again.