I've been looking at parse_as_rest(...) myself lately for use as a REST api for AngularJS and after studying the code in DAL I've discovered there are some undocumented features to the parse_as_rest method(...). I'm guessing they are undocumented because it is still considered as experimental and could change in future versions of web2py so YMMV.
Basically an item in the `patterns` list can be a tuple with the first item being the pattern as a string and the second item being a DAL query object like so: db.define_table('person',Field('name'),Field('info')) db.define_table('pet',Field('ownedby',db.person),Field('name'),Field('info')) ... patterns = [ "/friends[person]", "/{person.name}/:field", "/{person.name}/pets[pet.ownedby]", "/{person.name}/pets[pet.ownedby]/{pet.name}", "/{person.name}/pets[pet.ownedby]/{pet.name}/:field", ("/dogs[pet]", db.pet.info=='dog'), ("/dogs[pet]/{pet.name.startswith}", db.pet.info=='dog'), ] When the pattern is matched the provided query object is included. Since auth.accessible_query(...) returns a DAL query object I'm guessing you could use the patterns list just like any other DAL query. The tuple can also take a third item which can be a list of field names to limit what you want returned from the query: patterns = [ ... ("/dogs[pet]", db.pet.info=='dog', ['name']), ... ] You can experiment around with this and see if it gets you what you need. But like I stated earlier... it is an experimental feature, so use caution as this could change in future versions of web2py and break your app. FYI: It also looks like a list of "queries" can be passed into the parse_as_rest(...) method, but I haven't studied the code closely enough to work out exactly how its intended to be used. parse_as_rest(self, patterns, args, vars, queries=None, nested_select=True) Maybe someone who has a better understanding of the current state of the parse_as_rest(...) method can chime in here and add to this and/or correct anything I may be wrong about. On Friday, February 28, 2014 8:50:58 AM UTC-5, Zbigniew Pomianowski wrote: > > I know I can build standard queries, but is it possible to combine > *parse_as_rest(patterns, > args, vars)* with *auth.accessible_query(action, table)*? > -- 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/groups/opt_out.