[web2py] Re: More Details on RESTful web2py?
Hmm quite the same question as David G: I use the auto pattern feature (really nice) but I don't see how to provide an index for a resource. Am I missing something ? Thanks ! On Aug 9, 12:11 am, David G dgeorge.sie...@gmail.com wrote: I have a similar question as Web2py Newbie. I want to return all the rows from a table using a pattern like: /myapp/api/table I'm wondering if your answer for Newbie is specific to returning a single comment with the id of bookmark.id? How would you code the GET method to get all the comments? Thanks! On Jun 16, 6:43 am, Massimo Di Pierro massimo.dipie...@gmail.com wrote: Then you need to call /myapp/api/as_rest/1.json where api is the controller, as_rest is your function, 1 is the {bookmark.id}. On Jun 16, 12:51 am, Web2py Newbie swiawte...@garrifulio.mailexpire.com wrote: At the moment it is: @request.restful() def as_rest(): def GET(*args,**vars): patterns = ['/{bookmarks.id}', ''] parsed = db.parse_as_rest(patterns,args,vars) if parsed.status==200: return parsed.response.json() else: posts = db().select(db.bookmarks.ALL) return response.render('posts/index.html', locals()) On Jun 16, 12:58 pm, Massimo Di Pierro massimo.dipie...@gmail.com wrote: please show us your code. On Jun 15, 2:25 am, Web2py Newbie swiawte...@garrifulio.mailexpire.com wrote: As a follow up: I want to use something like: /myapp/api/show_comment/id to show comment at id and /myapp/api/show_comment/ To show all comments However, when I try this it complains (invalid arguments). I try to test id against None, but id is apparently a server object. Any ideas or do I just have to define all_comments?- Hide quoted text - - Show quoted text -
[web2py] Re: More Details on RESTful web2py?
I have a similar question as Web2py Newbie. I want to return all the rows from a table using a pattern like: /myapp/api/table I'm wondering if your answer for Newbie is specific to returning a single comment with the id of bookmark.id? How would you code the GET method to get all the comments? Thanks! On Jun 16, 6:43 am, Massimo Di Pierro massimo.dipie...@gmail.com wrote: Then you need to call /myapp/api/as_rest/1.json where api is the controller, as_rest is your function, 1 is the {bookmark.id}. On Jun 16, 12:51 am, Web2py Newbie swiawte...@garrifulio.mailexpire.com wrote: At the moment it is: @request.restful() def as_rest(): def GET(*args,**vars): patterns = ['/{bookmarks.id}', ''] parsed = db.parse_as_rest(patterns,args,vars) if parsed.status==200: return parsed.response.json() else: posts = db().select(db.bookmarks.ALL) return response.render('posts/index.html', locals()) On Jun 16, 12:58 pm, Massimo Di Pierro massimo.dipie...@gmail.com wrote: please show us your code. On Jun 15, 2:25 am, Web2py Newbie swiawte...@garrifulio.mailexpire.com wrote: As a follow up: I want to use something like: /myapp/api/show_comment/id to show comment at id and /myapp/api/show_comment/ To show all comments However, when I try this it complains (invalid arguments). I try to test id against None, but id is apparently a server object. Any ideas or do I just have to define all_comments?- Hide quoted text - - Show quoted text -
[web2py] Re: More Details on RESTful web2py?
At the moment it is: @request.restful() def as_rest(): def GET(*args,**vars): patterns = ['/{bookmarks.id}', ''] parsed = db.parse_as_rest(patterns,args,vars) if parsed.status==200: return parsed.response.json() else: posts = db().select(db.bookmarks.ALL) return response.render('posts/index.html', locals()) On Jun 16, 12:58 pm, Massimo Di Pierro massimo.dipie...@gmail.com wrote: please show us your code. On Jun 15, 2:25 am, Web2py Newbie swiawte...@garrifulio.mailexpire.com wrote: As a follow up: I want to use something like: /myapp/api/show_comment/id to show comment at id and /myapp/api/show_comment/ To show all comments However, when I try this it complains (invalid arguments). I try to test id against None, but id is apparently a server object. Any ideas or do I just have to define all_comments?
[web2py] Re: More Details on RESTful web2py?
Then you need to call /myapp/api/as_rest/1.json where api is the controller, as_rest is your function, 1 is the {bookmark.id}. On Jun 16, 12:51 am, Web2py Newbie swiawte...@garrifulio.mailexpire.com wrote: At the moment it is: @request.restful() def as_rest(): def GET(*args,**vars): patterns = ['/{bookmarks.id}', ''] parsed = db.parse_as_rest(patterns,args,vars) if parsed.status==200: return parsed.response.json() else: posts = db().select(db.bookmarks.ALL) return response.render('posts/index.html', locals()) On Jun 16, 12:58 pm, Massimo Di Pierro massimo.dipie...@gmail.com wrote: please show us your code. On Jun 15, 2:25 am, Web2py Newbie swiawte...@garrifulio.mailexpire.com wrote: As a follow up: I want to use something like: /myapp/api/show_comment/id to show comment at id and /myapp/api/show_comment/ To show all comments However, when I try this it complains (invalid arguments). I try to test id against None, but id is apparently a server object. Any ideas or do I just have to define all_comments?
[web2py] Re: More Details on RESTful web2py?
As a follow up: I want to use something like: /myapp/api/show_comment/id to show comment at id and /myapp/api/show_comment/ To show all comments However, when I try this it complains (invalid arguments). I try to test id against None, but id is apparently a server object. Any ideas or do I just have to define all_comments?
[web2py] Re: More Details on RESTful web2py?
H it seems to have just dropped my supplementary question. Apologies if this arrives twice. I want to do something like: /myapp/api/get_comment/id to return the comment at id and /myapp/api/get_comment/ to return a list of all comments However, it complains when I try this (invalid argument). I try to test id against None, but it's a server object so isn't None. Is this doable or do I give up and define get_all_comments?
[web2py] Re: More Details on RESTful web2py?
Apparently: wait for a pattern failure and work with that? if parsed.status==200: return parsed.response.json() else: maybe some test for kind of parse error print out the whole
[web2py] Re: More Details on RESTful web2py?
please show us your code. On Jun 15, 2:25 am, Web2py Newbie swiawte...@garrifulio.mailexpire.com wrote: As a follow up: I want to use something like: /myapp/api/show_comment/id to show comment at id and /myapp/api/show_comment/ To show all comments However, when I try this it complains (invalid arguments). I try to test id against None, but id is apparently a server object. Any ideas or do I just have to define all_comments?