I actually agree. Right now my "solution" is to put this in my controller
file:
def parent_controller(views_folder=None, pop_args_zero=True):
if views_folder is None:
views_folder = os.path.join(request.controller, request.function)
def wrapper(action):
def f(_action=action, *a, **b):
command = None
try:
if pop_args_zero:
parseme = request.args.pop(0)
else:
parseme = request.args(0)
if '.' in parseme:
try:
command, extension = parseme.split('.')
except ValueError:
raise HTTP(400, "invalid arguments")
else:
command, extension = parseme, 'html'
except (IndexError, TypeError): # pop from empty list
command, extension = 'index', 'html'
response.view = os.path.join(views_folder, command + '.' +
extension)
requested_controller = _action().get(command, None)
if requested_controller:
return requested_controller()
else:
raise HTTP(404)
f.__doc__ = action.__doc__
f.__name__ = action.__name__
return f
return wrapper
Then I can have a controller function like this:
@parentcontroller()
def persons():
def index():
return {}
def update_or_insert():
return {}
return locals()
Then on the views I can have a folder structure like this
[default] [persons] . .. index.html update_or_insert.html
This solution isn't ideal. We should probably support the regular module
structure in controllers.
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
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 [email protected].
For more options, visit https://groups.google.com/d/optout.