Imagine the following table:
db.define_table('project',
Field('name', required=True),
Field('admin_user', 'reference auth_user', default=auth.
user_id, required=True),
Field('users', 'list:reference auth_user'),
migrate=True
)
@request.restful()
def api():
response.view = 'generic.json'
def GET(*args, **vars):
patterns = [
"/projects[project]",
"/project/{project.id}",
"/users[auth_user]",
"/user/{auth_user.id}",
]
parser = db.parse_as_rest(patterns, args, vars)
if parser.status == 200:
return dict(content=parser.response)
else:
raise HTTP(parser.status, parser.error)
Ideally requesting all projects would already contain the information on
the admin and all its users. I tried specifying a query to get an inner
join but this did not work:
parser = db.parse_as_rest(patterns, args, vars, queries={'project':
(db.project.admin_user == db.auth_user.id)})
I am obviously missing something here. Can someone please point me into the
right direction?
Thanks
Ben
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.