From 20576684dd94323ab1325706a10e3bad81dde28b Mon Sep 17 00:00:00 2001 From: Tim Richardson Date: Fri, 31 Jan 2014 12:02:46 +1100 Subject: [PATCH] Step 1 in fixing 1859: this stops the crashing, but virtual fields are not exported --- gluon/sqlhtml.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/gluon/sqlhtml.py b/gluon/sqlhtml.py index 573b498f..de6179cc 100644 --- a/gluon/sqlhtml.py +++ b/gluon/sqlhtml.py @@ -2181,29 +2181,34 @@ class SQLFORM(FORM): orderby = (order[:1] == '~' and ~sort_field) or sort_field expcolumns = [str(f) for f in columns] + selectable_columns = [str(f) for f in columns if not isinstance(f,Field.Virtual)] if export_type.endswith('with_hidden_cols'): expcolumns = [] + selectable_columns=[] #like expcolumns but excluding virtual for table in tables: for field in table: if field.readable and field.tablename in tablenames: expcolumns.append(field) + if not(isinstance(field,Field.Virtual)): + selectable_columns.append(field) if export_type in exportManager and exportManager[export_type]: if request.vars.keywords: try: - #the query should be constructed using searchable fields + #the query should be constructed using searchable fields but not virtual fields sfields = reduce(lambda a, b: a + b, - [[f for f in t if f.readable] for t in tables]) + [[f for f in t if f.readable and not isinstance(f,Field.Virtual)] for t in tables]) + #how to put virtual fields back? dbset = dbset(SQLFORM.build_query( sfields, request.vars.get('keywords', ''))) rows = dbset.select(left=left, orderby=orderby, - cacheable=True, *expcolumns) + cacheable=True, *selectable_columns) except Exception, e: response.flash = T('Internal Error') rows = [] else: rows = dbset.select(left=left, orderby=orderby, - cacheable=True, *expcolumns) + cacheable=True, *selectable_columns) value = exportManager[export_type] clazz = value[0] if hasattr(value, '__getitem__') else value