Many apps in a single app.

92 views
Skip to first unread message

António Ramos

unread,
Jul 5, 2019, 9:13:00 AM7/5/19
to web...@googlegroups.com
Just wanted to share my workspace where in the same app i can have as many apps as i want.
I have as default entry an app where i can see all my tasks from any app that uses wokflow that creates tasks/events.
From there i can follow my tasks or i can swith to another app via a workspace page and loading that app can load different menus and layouts.
I have a controller for each app, a models.py for each app ,etc
image.png
image.png
image.png
This way i only have one app that shares users/permissions/groups and all the goodies i have already created.

Regards
António 

villas

unread,
Jul 5, 2019, 11:15:04 AM7/5/19
to web2py-users
Very nice Antonio.
My organisation has several apps, but each user has to log in separately for each app, even though we use the same auth_users table for authentication.
Would you please explain a little more because I might refactor our apps to work in the way you suggest...
Thanks! 

António Ramos

unread,
Jul 5, 2019, 12:25:10 PM7/5/19
to web...@googlegroups.com
Something like this
image.png
image.png

--
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+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/b5fdb440-6200-45ec-9182-5ef2198d2bbe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

António Ramos

unread,
Jul 5, 2019, 12:26:42 PM7/5/19
to web...@googlegroups.com
ignore the previous image
this replaces it
image.png

António Ramos

unread,
Jul 5, 2019, 12:48:02 PM7/5/19
to web...@googlegroups.com
Then to get all apps in the same screen i created a workspace.html inside views  " named after Lotus Notes workspace for those who know what it is..."
I would like an automatic process to detect all apps but for now i just do it from an array that i update every time i have a new one.

image.png

villas

unread,
Jul 9, 2019, 5:08:21 PM7/9/19
to web2py-users
Now I understand it better.  I will consider this strategy for future.
Thanks!
To unsubscribe from this group and stop receiving emails from it, send an email to web...@googlegroups.com.

Leonel Câmara

unread,
Jul 9, 2019, 5:56:35 PM7/9/19
to web2py-users
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.

Daniel Guilhermino

unread,
Jul 19, 2019, 8:24:11 AM7/19/19
to web2py-users
Leonel,

very interesting this possibility, it is possible to avoid rewriting enough thing, thanks for sharing!
Reply all
Reply to author
Forward
0 new messages