108 def appendRow(self, cellData, rowAttr=''):
109 """Append a row to the table. cellData is a list of the contents of
110 the cells in the row. The data for each cell is either a string
111 with the contents of the cell, or a tuple where the first element
112 is the contents of the cell and the second element contains any
113 HTML tags. Special HTML characters are properly replaced (using
114 escape from cgi) if escapeText was set True when creating the
115 table. If the table uses Tablesorter, <th> is used instead of
116 <td> in the first row."""
117 r = '<tr%s>\n' % sep(rowAttr)
118 if self.useTableSorter and len(self.rows)==0:
119
120 cellFormat = '<th%s>%s</th>\n'
121 else:
122 cellFormat = '<td%s>%s</td>\n'
123 iCell = 0
124 for c in cellData:
125 cellAttr = self.defaultCellAttr[iCell] if iCell<len(self.defaultCellAttr) else ''
126 if isinstance(c,tuple):
127 r += cellFormat % (sep(c[1]),escape(str(c[0])) if self.escapeText else str(c[0]))
128 else:
129 r += cellFormat % (sep(cellAttr),escape(str(c)) if self.escapeText else str(c))
130 iCell += 1
131 r += '</tr>'
132 self.rows.append(r)
133