From 35840bc572c58724756e58ab3ad48dd8a10ceae0 Mon Sep 17 00:00:00 2001 From: Prasad Muley Date: Fri, 16 Jan 2015 21:01:33 +0530 Subject: [PATCH] Fix: Exporting from a SQLFORM.grid with customized search queries Massimo manually applied older diff file. He also merged my newer diff file. So Optimized code --- gluon/sqlhtml.py | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/gluon/sqlhtml.py b/gluon/sqlhtml.py index e3171010..df9e8f0f 100644 --- a/gluon/sqlhtml.py +++ b/gluon/sqlhtml.py @@ -2326,7 +2326,7 @@ class SQLFORM(FORM): expcolumns.append(str(field)) if export_type in exportManager and exportManager[export_type]: - if keywords and not callable(searchable): + if keywords: try: #the query should be constructed using searchable #fields but not virtual fields @@ -2343,19 +2343,6 @@ class SQLFORM(FORM): except Exception, e: response.flash = T('Internal Error') rows = [] - elif callable(searchable): - #use custom_query using searchable - try: - #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 and not isinstance(f, Field.Virtual)] for t in tables]) - dbset = dbset(searchable(sfields, keywords)) - rows = dbset.select(left=left, orderby=orderby, - cacheable=True, *selectable_columns) - except Exception, e: - response.flash = T('Internal Error') - rows = [] else: rows = dbset.select(left=left, orderby=orderby, cacheable=True, *selectable_columns)