Nice. :-D
On Thu, Oct 28, 2010 at 11:20 AM, mdipierro <[email protected]> wrote: > Out of the box you can do: > > @service.run > def insertdog(name,owner,age): > # other things > > and in routes: > > routes_in=[ > ('/app/default/insertdog/$name/$age/$owner', > '/app/default/call/run/insertdog/$name/$age/$owner')] > > I guess we can make another decorator that automatically registers the > routes. > > > On Oct 28, 3:39 am, cjrh <[email protected]> wrote: >> On Oct 28, 9:53 am, cjrh <[email protected]> wrote: >> >> > On Oct 27, 5:43 pm, VP <[email protected]> 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)

