Hi guys!
I am using the wonderful db.parse_as_rest function in my development and
like to ask if it is possible to push a modification in the trunk as as to
be able to go on without custom code maintenance :)
For paging purposes, I would need the output of this function to contain
the total number of records returned by the request (before limits
applies). Fortunately, this is already computed by the function:
if i==len(tags) and table:
ofields = vars.get('order',db[table]._id.name).split('|'
)
try:
orderby = [db[table][f] if not f.startswith('~')
else ~db[table][f[1:]] for f in ofields]
except KeyError:
return Row({'status':400,'error':'invalid orderby',
'response':None})
fields = [field for field in db[table] if field.readable
]
count = dbset.count()
try:
offset = int(vars.get('offset',None) or 0)
limits = (offset,int(vars.get('limit',None) or 1000
)+offset)
except ValueError:
Row({'status':400,'error':'invalid limits',
'response':None})
if count > limits[1]-limits[0]:
Row({'status':400,'error':'too many records',
'response':None})
try:
response = dbset.select(limitby=limits,orderby=
orderby,*fields)
except ValueError:
return Row({'status':400,'pattern':pattern,
'error':'invalid path','response':None})
return Row({'status':200,'response':response,'pattern':
pattern})
and so I would modify the last return to:
return Row({'status':200,'response':response,'pattern':
pattern,'count':count})
Would this be acceptable ?
Thanks in advance !!