I missed the part about customizing the columns/tags. Something like
this?
@service.run
def get_rows(table,start,end):
response.headers['Content-Type'] = 'text/xml'
from gluon.serializers import xml_rec
rows = db(db[table].id>0).select(limitby=(int(start),int(end)))
headers = dict()
for c in rows.colnames:
c = c.split('.')[1]
headers[c]=c
# customize headers here
out = TAG['document'](*[TAG['record'](*[TAG[headers[k]](xml_rec(v,
'')) for k, v in row.as_dict().items()]) for row in rows])
return out.xml()
On Dec 9, 11:08 am, mdipierro <[email protected]> wrote:
> @service.xml
> def get_rows(table,start,end)
> rows = db(db[table].id>0).select(limitby=(start,end))
> return rows.as_list()
>
> On Dec 9, 9:06 am, "mr.freeze" <[email protected]> wrote:
>
> > Try using @service.xml
>
> > @service.xml
> > def get_rows(table,start,end)
> > rows = db(db[table].id>0).select(limitby=(start,end))
> > return rows
>
> >http://127.0.0.1:8000/app/default/call/xml/get_rows?table=things&star...
>
> > On Dec 9, 5:06 am, Mikko <[email protected]> wrote:
>
> > > Hi,
>
> > > Any sniplet to export table as xml (would be nice include easy
> > > customization...)
> > > Old
> > > def export_xml(rows):
> > > idx=range(len(rows.colnames))
> > > colnames=[item.replace('.','_') for item in rows.colnames]
> > > records=[]
> > > for row in rows.response: records.append(TAG['record'](*[TAG
> > > [colnames[i]](row[i]) for i in idx]))
>
> > > aviously doesnt work
>
> > > Mikko
> > > -
>
>
--
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en.