db().select().xml(strict=True)
This commit is contained in:
@@ -1 +1 @@
|
||||
Version 2.00.0 (2012-08-25 23:06:24) dev
|
||||
Version 2.00.0 (2012-08-25 23:54:19) dev
|
||||
|
||||
+28
-3
@@ -7519,7 +7519,7 @@ class Table(dict):
|
||||
yield self[fieldname]
|
||||
|
||||
def __repr__(self):
|
||||
return '<Table %s>' % dict.__repr__(self)
|
||||
return '<Table %s (%s)>' % (self._tablename,','.join(self.fields()))
|
||||
|
||||
def __str__(self):
|
||||
if self.get('_ot', None):
|
||||
@@ -8381,6 +8381,9 @@ class Query(object):
|
||||
self.second = second
|
||||
self.ignore_common_filters = ignore_common_filters
|
||||
|
||||
def __repr__(self):
|
||||
return '<Query %s>' % BaseAdapter.expand(self.db._adapter,self)
|
||||
|
||||
def __str__(self):
|
||||
return self.db._adapter.expand(self)
|
||||
|
||||
@@ -8437,6 +8440,9 @@ class Set(object):
|
||||
query.ignore_common_filters = ignore_common_filters
|
||||
self.query = query
|
||||
|
||||
def __repr__(self):
|
||||
return '<Set %s>' % BaseAdapter.expand(self.db._adapter,self.query)
|
||||
|
||||
def __call__(self, query, ignore_common_filters=False):
|
||||
if isinstance(query,Table):
|
||||
query = query._id>0
|
||||
@@ -8617,6 +8623,9 @@ class Rows(object):
|
||||
self.compact = compact
|
||||
self.response = rawrows
|
||||
|
||||
def __repr__(self):
|
||||
return '<Rows (%s)>' % len(self.records)
|
||||
|
||||
def setvirtualfields(self,**keyed_virtualfields):
|
||||
"""
|
||||
db.define_table('x',Field('number','integer'))
|
||||
@@ -8877,11 +8886,27 @@ class Rows(object):
|
||||
row.append(none_exception(value))
|
||||
writer.writerow(row)
|
||||
|
||||
def xml(self):
|
||||
def xml(self,strict=False):
|
||||
"""
|
||||
serializes the table using sqlhtml.SQLTABLE (if present)
|
||||
"""
|
||||
|
||||
if strict:
|
||||
ncols = len(self.colnames)
|
||||
def f(row,field='row',indent=' '):
|
||||
if isinstance(row,dict):
|
||||
spc = indent+' \n'
|
||||
items = [f(row[x],x,indent+' ') for x in row]
|
||||
return '%s<%s>\n%s\n%s</%s>' % (
|
||||
indent,
|
||||
field,
|
||||
spc.join(item for item in items if item),
|
||||
indent,
|
||||
field)
|
||||
elif not callable(row):
|
||||
return '%s<%s>%s</%s>' % (indent,field,row,field)
|
||||
else:
|
||||
return None
|
||||
return '<rows>\n%s\n</rows>' % '\n'.join(f(row) for row in self)
|
||||
import sqlhtml
|
||||
return sqlhtml.SQLTABLE(self).xml()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user