Is the decorated index function in the "mod" controller? If so, doesn't this result in an infinite redirect loop (i.e., visit index -> no session.active_mod -> redirect to index -> still no session.active_mod -> repeat...)? Shouldn't the decorator either set a session.active_mod or redirect to a non-decorated function?
Anthony On Wednesday, February 27, 2013 1:19:59 PM UTC-5, Zach wrote: > > Hi guys I don't knwo whether this was posted the first time ok, so I am > reposting. basically I have an app that I want to check the existence of a > session parameter prior to accessing some functions. since these are > different functions in different controllers I created a model with the > folllowing decorator in it: > > model.py > > def check_mod_set_active(callee): > if session.active_mod == None: > session.flash = 'No active module selected.' > redirect(URL('mod', 'index')) > else: > return callee > > if a controller (test.py) I have: > > @check_mod_set_active > def index(): return dict(message="hello from test.py") > > def index2(): return dict(message="hello from test.py") > > index should require the existence of the session variable and index2 > shouldn't. My problem is that @check_mod_set_active is taken under > consideration for index2 as well. what have I messed up ? > > Cheers, > Zach > > Apologies if someone gets this twice. > -- --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.