This looks good, if you want to take it a step further and have something 
like sub-controller-functions in your apps that will have their own views 
folder inside the app views folder you can use this decorator I made:

def parent_controller(views_folder=None, pop_args_zero=True):
    """
    Decorator to turn a controller function into a parent of other 
controller
    functions.

    This allows you to have many controller functions in a single controller
    function each having their own view inside a folder.

    :views_folder: Folder where it gets the views for the children 
controllers
                   by default uses the parent controller name.
    :pop_args_zero: whether to remove or not the name of the children 
controller
                    from request.args. By default 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 in the app1.py controller you could do something like:

@auth.requires_login()
@parent_controller()
def pages():
    def index():
        ...
        return {}

    def insert():
        ...
        return something

    def delete():
        ...
        return something

    return locals()

And in the views you would have

app1/
    pages/
        index.html
        insert.html
        delete.html


@villas note that in your case it's probably better to have a single 
application do the log in and then use CAS.

-- 
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 web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/6d83a89c-e41a-44ef-9022-735dc2d75157%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to