.parse_as_rest() returns a Row object with one of the attributes being 
"count" (if you submit a query for multiple records and it is successful):

@request.restful()
def api():
    response.view = 'generic.' + request.extension

    def GET(*args, **vars):
        patterns = 'auto'
        parser = db.parse_as_rest(patterns, args, vars)
        if parser.status == 200:
            return dict(content=parser.response, count=parser.get('count'))
        else:
            raise HTTP(parser.status, parser.error)
 
    ...

    return locals()

The above uses parser.get('count') rather than parser.count because the 
latter would cause an error if there is no "count" returned.

Anthony

On Wednesday, September 13, 2017 at 9:03:16 PM UTC-4, Carlos A. Armenta 
Castro wrote:
>
> Hi folks
>
> I want to get the total rows (count) of a query (get request) in a Restful 
> Web Services ( parse_as_rest ). Is it possible? Or I need to construct my 
> own custom method for this purpose?
>
> I know I can limit the number of records by specifying a limit and offset GET 
> variables
>
> http://..../api/friends?offset=10&limit=1000
>
>
> But for certains applications this is not enough (at least for me).
>
> Thank you in advance!!!!
>
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to