From 8fdedb70181526a2f581d0d737a28c31e7f40de9 Mon Sep 17 00:00:00 2001 From: Oscar Fonts Date: Mon, 13 Jun 2016 12:17:45 +0200 Subject: [PATCH 1/2] Add maxtextlenth option to SQLFORM.grid HTML exporter --- gluon/sqlhtml.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/gluon/sqlhtml.py b/gluon/sqlhtml.py index 5cdb9147..23b9642e 100644 --- a/gluon/sqlhtml.py +++ b/gluon/sqlhtml.py @@ -2476,7 +2476,8 @@ class SQLFORM(FORM): response.headers['Content-Type'] = oExp.content_type response.headers['Content-Disposition'] = \ 'attachment;filename=' + filename + ';' - raise HTTP(200, oExp.export(), **response.headers) + document = oExp.export(maxtextlength) if oExp.__class__.__name__== 'ExporterHTML' else oExp.export() + raise HTTP(200, document, **response.headers) elif request.vars.records and not isinstance( request.vars.records, list): @@ -3549,9 +3550,9 @@ class ExporterHTML(ExportClass): def __init__(self, rows): ExportClass.__init__(self, rows) - def export(self): - xml = self.rows.xml() if self.rows else '' - return '\n\n\n\n\n%s\n\n' % (xml or '') + def export(self, truncate=16): + table = SQLTABLE(self.rows, truncate=truncate) if self.rows else '' + return '\n\n\n\n\n%s\n\n' % (table or '') class ExporterXML(ExportClass): From 11fec259279648bac1d3f7b3dff914b1d26e8fed Mon Sep 17 00:00:00 2001 From: Oscar Fonts Date: Tue, 14 Jun 2016 11:06:14 +0200 Subject: [PATCH 2/2] Don't truncate texts on SQLFORM.grid HTML Export --- gluon/sqlhtml.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/gluon/sqlhtml.py b/gluon/sqlhtml.py index 23b9642e..51055c6c 100644 --- a/gluon/sqlhtml.py +++ b/gluon/sqlhtml.py @@ -2476,8 +2476,7 @@ class SQLFORM(FORM): response.headers['Content-Type'] = oExp.content_type response.headers['Content-Disposition'] = \ 'attachment;filename=' + filename + ';' - document = oExp.export(maxtextlength) if oExp.__class__.__name__== 'ExporterHTML' else oExp.export() - raise HTTP(200, document, **response.headers) + raise HTTP(200, oExp.export(), **response.headers) elif request.vars.records and not isinstance( request.vars.records, list): @@ -3550,8 +3549,8 @@ class ExporterHTML(ExportClass): def __init__(self, rows): ExportClass.__init__(self, rows) - def export(self, truncate=16): - table = SQLTABLE(self.rows, truncate=truncate) if self.rows else '' + def export(self): + table = SQLTABLE(self.rows, truncate=None) if self.rows else '' return '\n\n\n\n\n%s\n\n' % (table or '')