This is really cool! I think it deserves a decorator.
@action_wrapper() def my_action_wrapper(): def one_action(): return dict() def another_action(): return dict() So the decorator adds the "return locals().get..." part 2011/2/18 Massimo Di Pierro <massimo.dipie...@gmail.com> > cool. I never thought about this. You can make it much simpler: > > > def users(): > def index(): > return dict(message="List users") > def new(): > return dict(message="Add new user") > def edit(): > return dict(message="Edit an existing user") > return locals().get(request.args(0),'not defined') > > On Feb 18, 12:47 pm, Ross Peoples <ross.peop...@gmail.com> wrote: > > I am trying to make an 'admin' controller that will allow > > administrators of the app to administer different parts of the app. > > One of the things to administer will be listing, adding, and removing > > of users. So, ideally, I would like my URL structure to be like this: > > "/[app]/admin/users/index". I have found a way to make it work, but I > > was wondering if there is a better way. This is my admin.py controller > > so far: > > > > def index(): > > return dict(message="This will eventually return a window allowing > > you to select different administrative options.") > > > > def users(): > > def index(): > > return dict(message="List users") > > > > def new(): > > return dict(message="Add new user") > > > > def edit(): > > return dict(message="Edit an existing user") > > > > if request.args(0): > > action = request.args(0) > > if action == 'new': > > return new() > > elif action == 'edit': > > return edit() > > else: > > return index() > > else: > > return index() > > > > So am I going about this the right way, or am I totally off base? > > Thanks. >