wiki:BluePrintRESTImplementation

Version 5 (modified by Fran Boon, 16 years ago) ( diff )

if t2.logged_in() for some methods only

# RESTful controller function
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":
                if t2.logged_in:
                    form=t2.update(db.gis_feature)
                    response.view='gis/update_feature.html'
                    return dict(module_name=module_name,modules=modules,options=options,form=form)
                else:
                    t2.redirect('login')
            elif method=="delete":
                t2.delete(db.gis_feature,next='features')
                return
            else:
                # Invalid!
                return
    else:
        # List Features
        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.