This is the result of a brainstorming session at PyCon with web2py
users Jay, Kevin, Shawn and Nathan.

We could use some help with testing and more importantly usability.

Please check out trunk and put this in your code


@request.restful()
def api():
    def GET(*args,**vars):
        parser = db.parse_as_rest("all",args,vars)
        if parser.status == 200:
            return dict(content=parser.response)
        else:
            raise HTTP(parser.status,parser.error)
    return locals()

then visit

/<yourapp>/default/api/list.json

you will get a list of patterns for example /table-by-field/
{table.field}/:field
where table and field will be some of your tables and fields. Now try
a pattern, for example the one mentioned

/<yourapp>/default/api/table-by-field/<value for table.field>/
<fieldname>

You can create your own patterns. They can be complex and involve
multiple tables. There is a more complex example in db.parse_as_rest
docstring.

What do you think? Is this general enough?

Massimo


Reply via email to