Skip to content

Commit

Permalink
Merge pull request web2py#591 from prasadmuley/issue2006_export_custo…
Browse files Browse the repository at this point in the history
…mize_query_defined_in_searchable

Fix: Exporting from a SQLFORM.grid with customized search queries
  • Loading branch information
mdipierro committed Jan 16, 2015
2 parents f840cda + 35840bc commit fe34d78
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions gluon/sqlhtml.py
Original file line number Diff line number Diff line change
Expand Up @@ -2326,7 +2326,7 @@ def linsert(lst, i, x):
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
Expand All @@ -2343,19 +2343,6 @@ def linsert(lst, i, x):
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)
Expand Down

0 comments on commit fe34d78

Please sign in to comment.