wiki:BluePrintRESTImplementation

Version 4 (modified by Fran Boon, 14 years ago) ( diff )

--

# RESTful controller function
# Since some methods should require authentication, we must do so for all (unless we patch T2)
@t2.requires_login('login')
def feature():
    if request.args:
        method=request.args[0]
        try:
            id = int(method)
            item=t2.display(db.gis_feature)
            response.view='gis/display_feature.html'
            return dict(module_name=module_name,modules=modules,options=options,item=item)
        except:
            if method=="create":
                form=t2.create(db.gis_feature)
                response.view='gis/add_feature.html'
                return dict(module_name=module_name,modules=modules,options=options,form=form)
            elif method=="display":
                item=t2.display(db.gis_feature)
                response.view='gis/display_feature.html'
                return dict(module_name=module_name,modules=modules,options=options,item=item)
            elif method=="update":
                form=t2.update(db.gis_feature)
                response.view='gis/update_feature.html'
                return dict(module_name=module_name,modules=modules,options=options,form=form)
            elif method=="delete":
                t2.delete(db.gis_feature,next='features')
                return
            else:
                # Invalid!
                return
    else:
        # List Features (NB currently simple)
        list=t2.itemize(db.gis_feature)
        response.view='gis/list.html'
        return dict(module_name=module_name,modules=modules,options=options,list=list)
Note: See TracWiki for help on using the wiki.