comparison sqlpyPlus.py @ 148:fcb19853cd94

improved accessibility of html template
author catherine@Elli.myhome.westell.com
date Thu, 25 Sep 2008 16:37:16 -0400
parents a2731c87b837
children 3b1e25cc0e38
comparison
equal deleted inserted replaced
147:a2731c87b837 148:fcb19853cd94
421 <html xmlns:py="http://genshi.edgewall.org/"> 421 <html xmlns:py="http://genshi.edgewall.org/">
422 <head> 422 <head>
423 <title py:content="tblname">Table Name</title> 423 <title py:content="tblname">Table Name</title>
424 </head> 424 </head>
425 <body> 425 <body>
426 <table py:attrs="{'id':tblname}"> 426 <table py:attrs="{'id':tblname,
427 'summary':'Result set from query on table ' + tblname}">
427 <tr> 428 <tr>
428 <th py:for="colname in colnames"> 429 <th py:for="colname in colnames"
430 py:attrs="{'id':'header_' + colname.lower()}">
429 <span py:replace="colname.lower()">Column Name</span> 431 <span py:replace="colname.lower()">Column Name</span>
430 </th> 432 </th>
431 </tr> 433 </tr>
432 <tr py:for="row in rows"> 434 <tr py:for="(colname, row) in zip(colnames, rows)">
433 <td py:for="itm in row"> 435 <td py:for="itm in row" py:attrs="{'headers':'header_' + colname.lower()}">
434 <span py:replace="str(itm)">Value</span> 436 <span py:replace="str(itm)">Value</span>
435 </td> 437 </td>
436 </tr> 438 </tr>
437 </table> 439 </table>
438 </body> 440 </body>
470 for row in self.rows: 472 for row in self.rows:
471 result.append(','.join('"%s"' % self.str_or_empty(itm) for itm in row)) 473 result.append(','.join('"%s"' % self.str_or_empty(itm) for itm in row))
472 result = '\n'.join(result) 474 result = '\n'.join(result)
473 elif outformat == '\\h': 475 elif outformat == '\\h':
474 result = self.html_template.generate(**self.__dict__) 476 result = self.html_template.generate(**self.__dict__)
475 elif outformat == '\\t': 477 elif outformat == '\\t': # transposed
476 rows = [self.colnames] 478 rows = [self.colnames]
477 rows.extend(list(self.rows)) 479 rows.extend(list(self.rows))
478 transpr = [[rows[y][x] for y in range(len(rows))]for x in range(len(rows[0]))] # matrix transpose 480 transpr = [[rows[y][x] for y in range(len(rows))]for x in range(len(rows[0]))] # matrix transpose
479 newdesc = [['ROW N.'+str(y),10] for y in range(len(rows))] 481 newdesc = [['ROW N.'+str(y),10] for y in range(len(rows))]
480 for x in range(len(self.curs.description)): 482 for x in range(len(self.curs.description)):