本文整理汇总了Python中gluon.sqlhtml.SQLFORM.build_query方法的典型用法代码示例。如果您正苦于以下问题:Python SQLFORM.build_query方法的具体用法?Python SQLFORM.build_query怎么用?Python SQLFORM.build_query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gluon.sqlhtml.SQLFORM
的用法示例。
在下文中一共展示了SQLFORM.build_query方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: grid
# 需要导入模块: from gluon.sqlhtml import SQLFORM [as 别名]
# 或者: from gluon.sqlhtml.SQLFORM import build_query [as 别名]
#.........这里部分代码省略.........
ondelete(table,request.args[-1])
ret = db(table[table._id.name]==request.args[-1]).delete()
return ret
exportManager = dict(
csv_with_hidden_cols=(ExporterCSV,'CSV (hidden cols)'),
csv=(ExporterCSV,'CSV'),
xml=(ExporterXML, 'XML'),
html=(ExporterHTML, 'HTML'),
tsv_with_hidden_cols=\
(ExporterTSV,'TSV (Excel compatible, hidden cols)'),
tsv=(ExporterTSV, 'TSV (Excel compatible)'))
if not exportclasses is None:
exportManager.update(exportclasses)
export_type = request.vars._export_type
if export_type:
order = request.vars.order or ''
if sortable:
if order and not order=='None':
if order[:1]=='~':
sign, rorder = '~', order[1:]
else:
sign, rorder = '', order
tablename,fieldname = rorder.split('.',1)
orderby=db[tablename][fieldname]
if sign=='~':
orderby=~orderby
table_fields = [f for f in fields if f._tablename in tablenames]
if export_type in ('csv_with_hidden_cols','tsv_with_hidden_cols'):
if request.vars.keywords:
try:
dbset = dbset(SQLFORM.build_query(
fields,request.vars.get('keywords','')))
rows = dbset.select(cacheable=True)
except Exception:
response.flash = T('Internal Error')
rows = []
else:
rows = dbset.select(cacheable=True)
else:
rows = dbset.select(left=left,orderby=orderby,
cacheable=True*columns)
if export_type in exportManager:
value = exportManager[export_type]
clazz = value[0] if hasattr(value, '__getitem__') else value
oExp = clazz(rows)
filename = '.'.join(('rows', oExp.file_ext))
response.headers['Content-Type'] = oExp.content_type
response.headers['Content-Disposition'] = \
'attachment;filename='+filename+';'
raise HTTP(200, oExp.export(),**response.headers)
elif request.vars.records and not isinstance(
request.vars.records,list):
request.vars.records=[request.vars.records]
elif not request.vars.records:
request.vars.records=[]
session['_web2py_grid_referrer_'+formname] = url2(vars=request.vars)
console = DIV(_class='web2py_console %(header)s %(cornertop)s' % ui)
error = None
search_actions = DIV(_class='web2py_search_actions')