annotate output_templates.py @ 153:ebdd20cfba69

plots finally editable
author catherine@Elli.myhome.westell.com
date Mon, 29 Sep 2008 05:28:28 -0400
parents 3b1e25cc0e38
children
rev   line source
149
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
1 import genshi.template
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
2
153
ebdd20cfba69 plots finally editable
catherine@Elli.myhome.westell.com
parents: 149
diff changeset
3 # To make more output formats available to sqlpython, just edit this
ebdd20cfba69 plots finally editable
catherine@Elli.myhome.westell.com
parents: 149
diff changeset
4 # file, or place a copy in your local directory and edit that.
ebdd20cfba69 plots finally editable
catherine@Elli.myhome.westell.com
parents: 149
diff changeset
5
ebdd20cfba69 plots finally editable
catherine@Elli.myhome.westell.com
parents: 149
diff changeset
6 output_templates = {
ebdd20cfba69 plots finally editable
catherine@Elli.myhome.westell.com
parents: 149
diff changeset
7
ebdd20cfba69 plots finally editable
catherine@Elli.myhome.westell.com
parents: 149
diff changeset
8 '\\x': genshi.template.NewTextTemplate("""
149
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
9 <xml>
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
10 <${tblname}_resultset>{% for row in rows %}
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
11 <$tblname>{% for (colname, itm) in zip(colnames, row) %}
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
12 <${colname.lower()}>$itm</${colname.lower()}>{% end %}
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
13 </$tblname>{% end %}
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
14 </${tblname}_resultset>
153
ebdd20cfba69 plots finally editable
catherine@Elli.myhome.westell.com
parents: 149
diff changeset
15 </xml>"""),
ebdd20cfba69 plots finally editable
catherine@Elli.myhome.westell.com
parents: 149
diff changeset
16
ebdd20cfba69 plots finally editable
catherine@Elli.myhome.westell.com
parents: 149
diff changeset
17 '\\h': genshi.template.MarkupTemplate("""
149
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
18 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
19 <html xmlns:py="http://genshi.edgewall.org/" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
20 <head>
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
21 <title py:content="tblname">Table Name</title>
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
22 <meta http-equiv="content-type" content="text/html;charset=utf-8" />
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
23 </head>
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
24 <body>
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
25 <table py:attrs="{'id':tblname,
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
26 'summary':'Result set from query on table ' + tblname}">
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
27 <tr>
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
28 <th py:for="colname in colnames"
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
29 py:attrs="{'id':'header_' + colname.lower()}">
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
30 <span py:replace="colname.lower()">Column Name</span>
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
31 </th>
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
32 </tr>
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
33 <tr py:for="(colname, row) in zip(colnames, rows)">
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
34 <td py:for="itm in row" py:attrs="{'headers':'header_' + colname.lower()}">
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
35 <span py:replace="str(itm)">Value</span>
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
36 </td>
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
37 </tr>
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
38 </table>
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
39 </body>
153
ebdd20cfba69 plots finally editable
catherine@Elli.myhome.westell.com
parents: 149
diff changeset
40 </html>"""),
149
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
41
153
ebdd20cfba69 plots finally editable
catherine@Elli.myhome.westell.com
parents: 149
diff changeset
42 '\\g': genshi.template.NewTextTemplate("""
149
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
43 {% for (rowNum, row) in enumerate(rows) %}
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
44 **** Row: ${rowNum + 1}
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
45 {% for (colname, itm) in zip(colnames, row) %}$colname: $itm
153
ebdd20cfba69 plots finally editable
catherine@Elli.myhome.westell.com
parents: 149
diff changeset
46 {% end %}{% end %}"""),
149
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
47
153
ebdd20cfba69 plots finally editable
catherine@Elli.myhome.westell.com
parents: 149
diff changeset
48 '\\G': genshi.template.NewTextTemplate("""
149
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
49 {% for (rowNum, row) in enumerate(rows) %}
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
50 **** Row: ${rowNum + 1}
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
51 {% for (colname, itm) in zip(colnames, row) %}${colname.ljust(colnamelen)}: $itm
153
ebdd20cfba69 plots finally editable
catherine@Elli.myhome.westell.com
parents: 149
diff changeset
52 {% end %}{% end %}"""),
ebdd20cfba69 plots finally editable
catherine@Elli.myhome.westell.com
parents: 149
diff changeset
53
ebdd20cfba69 plots finally editable
catherine@Elli.myhome.westell.com
parents: 149
diff changeset
54 }