From a63b8ca9ca5317f6744cc34dbdaa8d9e3634c4ae Mon Sep 17 00:00:00 2001 From: mdipierro Date: Thu, 15 Nov 2012 13:40:04 -0600 Subject: [PATCH] patches for @service.jsonrpc and exportclasses, thanks niphlod --- VERSION | 2 +- gluon/sqlhtml.py | 29 ++++++++++++++++------------- gluon/tools.py | 2 +- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/VERSION b/VERSION index f79b8aa6..5a5d7319 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.2.1 (2012-11-15 12:29:21) stable +Version 2.2.1 (2012-11-15 13:39:57) stable diff --git a/gluon/sqlhtml.py b/gluon/sqlhtml.py index b01b3818..eda4d05f 100644 --- a/gluon/sqlhtml.py +++ b/gluon/sqlhtml.py @@ -1731,12 +1731,18 @@ class SQLFORM(FORM): def url(**b): b['args'] = args + b.get('args', []) + localvars = request.vars.copy() + localvars.update(b.get('vars', {})) + b['vars'] = localvars b['hash_vars'] = False b['user_signature'] = user_signature return URL(**b) def url2(**b): b['args'] = request.args + b.get('args', []) + localvars = request.vars.copy() + localvars.update(b.get('vars', {})) + b['vars'] = localvars b['hash_vars'] = False b['user_signature'] = user_signature return URL(**b) @@ -1914,12 +1920,9 @@ class SQLFORM(FORM): tsv=(ExporterTSV, 'TSV (Excel compatible)')) if not exportclasses is None: """ - allow to set exportclasses=dict(csv=False) to disable the csv format + remember: allow to set exportclasses=dict(csv=False) to disable the csv format """ exportManager.update(exportclasses) - for k,v in exportclasses.items(): - if v is False: - del exportManager[k] export_type = request.vars._export_type if export_type: @@ -1935,24 +1938,22 @@ class SQLFORM(FORM): 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') - and export_type in exportManager): + expcolumns = columns + if export_type.endswith('with_hidden_cols'): + expcolumns = [f for f in fields if f._tablename in tablenames] + if export_type in exportManager and exportManager[export_type]: if request.vars.keywords: try: dbset = dbset(SQLFORM.build_query( fields, request.vars.get('keywords', ''))) - rows = dbset.select(cacheable=True) + rows = dbset.select(cacheable=True, *expcolumns) except Exception, e: response.flash = T('Internal Error') rows = [] else: - rows = dbset.select(cacheable=True) - else: - rows = dbset.select(left=left, orderby=orderby, - cacheable=True, *columns) + rows = dbset.select(left=left, orderby=orderby, + cacheable=True, *expcolumns) - if export_type in exportManager: value = exportManager[export_type] clazz = value[0] if hasattr(value, '__getitem__') else value oExp = clazz(rows) @@ -2283,6 +2284,8 @@ class SQLFORM(FORM): if csv and nrows: export_links = [] for k, v in sorted(exportManager.items()): + if not v: + continue label = v[1] if hasattr(v, "__getitem__") else k link = url2(vars=dict( order=request.vars.order or '', diff --git a/gluon/tools.py b/gluon/tools.py index 694413c9..45616074 100644 --- a/gluon/tools.py +++ b/gluon/tools.py @@ -4244,7 +4244,7 @@ class Service(object): if not method in methods: return return_error(id, 100, 'method "%s" does not exist' % method) try: - s = methods[method](*params) + s = methods[method](**params) if hasattr(s, 'as_list'): s = s.as_list() return return_response(id, s)