patches for @service.jsonrpc and exportclasses, thanks niphlod
This commit is contained in:
@@ -1 +1 @@
|
|||||||
Version 2.2.1 (2012-11-15 12:29:21) stable
|
Version 2.2.1 (2012-11-15 13:39:57) stable
|
||||||
|
|||||||
+16
-13
@@ -1731,12 +1731,18 @@ class SQLFORM(FORM):
|
|||||||
|
|
||||||
def url(**b):
|
def url(**b):
|
||||||
b['args'] = args + b.get('args', [])
|
b['args'] = args + b.get('args', [])
|
||||||
|
localvars = request.vars.copy()
|
||||||
|
localvars.update(b.get('vars', {}))
|
||||||
|
b['vars'] = localvars
|
||||||
b['hash_vars'] = False
|
b['hash_vars'] = False
|
||||||
b['user_signature'] = user_signature
|
b['user_signature'] = user_signature
|
||||||
return URL(**b)
|
return URL(**b)
|
||||||
|
|
||||||
def url2(**b):
|
def url2(**b):
|
||||||
b['args'] = request.args + b.get('args', [])
|
b['args'] = request.args + b.get('args', [])
|
||||||
|
localvars = request.vars.copy()
|
||||||
|
localvars.update(b.get('vars', {}))
|
||||||
|
b['vars'] = localvars
|
||||||
b['hash_vars'] = False
|
b['hash_vars'] = False
|
||||||
b['user_signature'] = user_signature
|
b['user_signature'] = user_signature
|
||||||
return URL(**b)
|
return URL(**b)
|
||||||
@@ -1914,12 +1920,9 @@ class SQLFORM(FORM):
|
|||||||
tsv=(ExporterTSV, 'TSV (Excel compatible)'))
|
tsv=(ExporterTSV, 'TSV (Excel compatible)'))
|
||||||
if not exportclasses is None:
|
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)
|
exportManager.update(exportclasses)
|
||||||
for k,v in exportclasses.items():
|
|
||||||
if v is False:
|
|
||||||
del exportManager[k]
|
|
||||||
|
|
||||||
export_type = request.vars._export_type
|
export_type = request.vars._export_type
|
||||||
if export_type:
|
if export_type:
|
||||||
@@ -1935,24 +1938,22 @@ class SQLFORM(FORM):
|
|||||||
if sign == '~':
|
if sign == '~':
|
||||||
orderby = ~orderby
|
orderby = ~orderby
|
||||||
|
|
||||||
table_fields = [f for f in fields if f._tablename in tablenames]
|
expcolumns = columns
|
||||||
if (export_type in ('csv_with_hidden_cols', 'tsv_with_hidden_cols')
|
if export_type.endswith('with_hidden_cols'):
|
||||||
and export_type in exportManager):
|
expcolumns = [f for f in fields if f._tablename in tablenames]
|
||||||
|
if export_type in exportManager and exportManager[export_type]:
|
||||||
if request.vars.keywords:
|
if request.vars.keywords:
|
||||||
try:
|
try:
|
||||||
dbset = dbset(SQLFORM.build_query(
|
dbset = dbset(SQLFORM.build_query(
|
||||||
fields, request.vars.get('keywords', '')))
|
fields, request.vars.get('keywords', '')))
|
||||||
rows = dbset.select(cacheable=True)
|
rows = dbset.select(cacheable=True, *expcolumns)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
response.flash = T('Internal Error')
|
response.flash = T('Internal Error')
|
||||||
rows = []
|
rows = []
|
||||||
else:
|
else:
|
||||||
rows = dbset.select(cacheable=True)
|
rows = dbset.select(left=left, orderby=orderby,
|
||||||
else:
|
cacheable=True, *expcolumns)
|
||||||
rows = dbset.select(left=left, orderby=orderby,
|
|
||||||
cacheable=True, *columns)
|
|
||||||
|
|
||||||
if export_type in exportManager:
|
|
||||||
value = exportManager[export_type]
|
value = exportManager[export_type]
|
||||||
clazz = value[0] if hasattr(value, '__getitem__') else value
|
clazz = value[0] if hasattr(value, '__getitem__') else value
|
||||||
oExp = clazz(rows)
|
oExp = clazz(rows)
|
||||||
@@ -2283,6 +2284,8 @@ class SQLFORM(FORM):
|
|||||||
if csv and nrows:
|
if csv and nrows:
|
||||||
export_links = []
|
export_links = []
|
||||||
for k, v in sorted(exportManager.items()):
|
for k, v in sorted(exportManager.items()):
|
||||||
|
if not v:
|
||||||
|
continue
|
||||||
label = v[1] if hasattr(v, "__getitem__") else k
|
label = v[1] if hasattr(v, "__getitem__") else k
|
||||||
link = url2(vars=dict(
|
link = url2(vars=dict(
|
||||||
order=request.vars.order or '',
|
order=request.vars.order or '',
|
||||||
|
|||||||
+1
-1
@@ -4244,7 +4244,7 @@ class Service(object):
|
|||||||
if not method in methods:
|
if not method in methods:
|
||||||
return return_error(id, 100, 'method "%s" does not exist' % method)
|
return return_error(id, 100, 'method "%s" does not exist' % method)
|
||||||
try:
|
try:
|
||||||
s = methods[method](*params)
|
s = methods[method](**params)
|
||||||
if hasattr(s, 'as_list'):
|
if hasattr(s, 'as_list'):
|
||||||
s = s.as_list()
|
s = s.as_list()
|
||||||
return return_response(id, s)
|
return return_response(id, s)
|
||||||
|
|||||||
Reference in New Issue
Block a user