xml(row_name,rows_name)

This commit is contained in:
mdipierro
2012-08-26 00:00:15 -05:00
parent 25c4ee3704
commit 8d1b892406
2 changed files with 7 additions and 4 deletions
+1 -1
View File
@@ -1 +1 @@
Version 2.00.0 (2012-08-25 23:54:19) dev Version 2.00.0 (2012-08-26 00:00:11) dev
+6 -3
View File
@@ -8886,13 +8886,13 @@ class Rows(object):
row.append(none_exception(value)) row.append(none_exception(value))
writer.writerow(row) writer.writerow(row)
def xml(self,strict=False): def xml(self,strict=False,row_name='row',rows_name='rows'):
""" """
serializes the table using sqlhtml.SQLTABLE (if present) serializes the table using sqlhtml.SQLTABLE (if present)
""" """
if strict: if strict:
ncols = len(self.colnames) ncols = len(self.colnames)
def f(row,field='row',indent=' '): def f(row,field,indent=' '):
if isinstance(row,dict): if isinstance(row,dict):
spc = indent+' \n' spc = indent+' \n'
items = [f(row[x],x,indent+' ') for x in row] items = [f(row[x],x,indent+' ') for x in row]
@@ -8906,7 +8906,10 @@ class Rows(object):
return '%s<%s>%s</%s>' % (indent,field,row,field) return '%s<%s>%s</%s>' % (indent,field,row,field)
else: else:
return None return None
return '<rows>\n%s\n</rows>' % '\n'.join(f(row) for row in self) return '<%s>\n%s\n</%s>' % (
rows_name,
'\n'.join(f(row,row_name) for row in self),
rows_name)
import sqlhtml import sqlhtml
return sqlhtml.SQLTABLE(self).xml() return sqlhtml.SQLTABLE(self).xml()