On Oct 28, 9:53 am, cjrh <caleb.hatti...@gmail.com> wrote: > 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:
Naturally, this closer simulation of app.route syntax also works (but I think the former separate arguments form works better): class R(object): pass request = R() request.args=['caleb', 100] def validator(route): args = route.split('/')[2:] args = [i.replace('<', '').replace('>', '') for i in 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 @validator('/controller_action/<first_name>/<age>') def controller_action(): return f.first_name, f.age print f() ================== OUTPUT: ('caleb', 100)