On Oct 27, 5:43 pm, VP <vtp2...@gmail.com> wrote: > @app.route('/insertdog/<name>/<age>/<owner>') > def insertdog(name,owner,age): > # other things
For fun, I tried an experiment with decorators. Hold onto your seats: # Simulation of the request object class R(object): pass request = R() request.args=['caleb', 100] # A validating decorator---put somewhere in web2py def validator(*args): assert(len(args)==len(request.args)) def inner(f): for name, value in zip(args, request.args): setattr(f, name, value) return f return inner # ************************************************** # This is how it will be used in the controller file # ************************************************** @validator('first_name', 'age') def controller_action(): return controller_action.first_name, controller_action.age ============== OUTPUT: ('caleb', 100) >>>