xml(row_name,rows_name)
This commit is contained in:
@@ -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
@@ -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()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user