149
|
1 import genshi.template
|
|
2
|
|
3 xml_template = genshi.template.NewTextTemplate("""
|
|
4 <xml>
|
|
5 <${tblname}_resultset>{% for row in rows %}
|
|
6 <$tblname>{% for (colname, itm) in zip(colnames, row) %}
|
|
7 <${colname.lower()}>$itm</${colname.lower()}>{% end %}
|
|
8 </$tblname>{% end %}
|
|
9 </${tblname}_resultset>
|
|
10 </xml>""")
|
|
11
|
|
12 html_template = genshi.template.MarkupTemplate("""
|
|
13 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
14 <html xmlns:py="http://genshi.edgewall.org/" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
15 <head>
|
|
16 <title py:content="tblname">Table Name</title>
|
|
17 <meta http-equiv="content-type" content="text/html;charset=utf-8" />
|
|
18 </head>
|
|
19 <body>
|
|
20 <table py:attrs="{'id':tblname,
|
|
21 'summary':'Result set from query on table ' + tblname}">
|
|
22 <tr>
|
|
23 <th py:for="colname in colnames"
|
|
24 py:attrs="{'id':'header_' + colname.lower()}">
|
|
25 <span py:replace="colname.lower()">Column Name</span>
|
|
26 </th>
|
|
27 </tr>
|
|
28 <tr py:for="(colname, row) in zip(colnames, rows)">
|
|
29 <td py:for="itm in row" py:attrs="{'headers':'header_' + colname.lower()}">
|
|
30 <span py:replace="str(itm)">Value</span>
|
|
31 </td>
|
|
32 </tr>
|
|
33 </table>
|
|
34 </body>
|
|
35 </html>""")
|
|
36
|
|
37 list_template = genshi.template.NewTextTemplate("""
|
|
38 {% for (rowNum, row) in enumerate(rows) %}
|
|
39 **** Row: ${rowNum + 1}
|
|
40 {% for (colname, itm) in zip(colnames, row) %}$colname: $itm
|
|
41 {% end %}{% end %}""")
|
|
42
|
|
43 aligned_list_template = genshi.template.NewTextTemplate("""
|
|
44 {% for (rowNum, row) in enumerate(rows) %}
|
|
45 **** Row: ${rowNum + 1}
|
|
46 {% for (colname, itm) in zip(colnames, row) %}${colname.ljust(colnamelen)}: $itm
|
|
47 {% end %}{% end %}""")
|