Hello,
I have component tools, they serve to show table build from a query with
redirect link. I place them in differents places in my app and depending of
the place I would like to be able to pass max number of rows to the
underling query used to build the table showed in the component. So I could
do :
{{=LOAD(c='dashboard_tools', f='tool1', *vars=dict(minrows=0, maxrows=10)*,
extension='load', ajax=True)}}
But if I would like to have all the records... What is the proper way??
My first thought was to pass maxrows=0 or -1 than query should return all
the records. But limitby it is not working like that.
Then I realize that passing only one parameter to the limitby (limitby=0)
would lead to what I want.
Since
db(db.table.id>0).select(db.table.ALL, limitby=(0))
Return all the records
So I could just do that :
{{=LOAD(c='dashboard_tools', f='tool1', *vars=dict(limitby=0)*,
extension='load', ajax=True)}}
or
{{=LOAD(c='dashboard_tools', f='tool1', *vars=dict(limitby=(0,10))*,
extension='load', ajax=True)}}
But the later seems not working because request.vars.limitby is a string...
This can easily be managed like this
{{=LOAD(c='dashboard_tools', f='tool1', *vars=dict(limitby='(0,10)')*,
extension='load', ajax=True)}}
eval(request.vars.limitby)
*But I am concerned about the security, should I??*
Other solution could be to stick with minrows, maxrows and :
if minrows or maxrows:
limitby=(int(request.vars.minrows),int(request.vars.maxrows)
else:
limitby=int(request.vars.minrows)
Maybe the book should contain little more explanation about the use of
limitby in context of URL and vars ?
Thank you.
Richard
--