Hi Massimo,

 

Got around to playing with Tags today (as per the new section you added to the 
py4web docs). Comments/feedback as follows:

 

As per the docs: 

 

groups=Tags(db.auth_user)

groups.add(user.id, 'Dancer')

 

1: nothing is added from inside an action

2: if I add the line groups.add(1, 'Dancer') right after the groups 
initialization it adds the record to the auth_user_tag_default table

 

That’s about as far as I have got.

 

Some grammatical stuff on the English but it is easily understandable for those 
that want to understand and certainly a lot better than I could do in Italian J

 

If have also noticed looking at the auth plugins that the port from web2py 
hasn’t quite been finalised with things like current and storage() still in the 
code. 

 

If you need a hand with proof reading/ correcting the docs you have done so far 
I am more than willing to help out.

 

Will continue to test and play and hopefully provide constructive feedback as 
part of the process.

 

Keep up the good work it is looking really cool !!!

 

Best Regards

John  

 

 

 

From: [email protected] [mailto:[email protected]] On Behalf Of 
Massimo Di Pierro
Sent: 01 October 2019 05:43
To: web2py-users
Subject: Re: [web2py] Re: py4web Auth

 

I understand what you are  asking. Something like the ability of web2py to 
define stuff in a models file and it would be available to the views. Problem 
with that design is the overhead. With py4web we are trying to be more 
efficient. 

 

There are many ways to do this:

 

1) create a function that returns the info you need and pass this function to 
the layout. For example:

 

def get_info(auth):

      return {... whatever you need ...}

 

@action('index')

@action.uses(auth)

def index():

        return dict(info=get_info(auth))

 

2) create a new fixture that injects data in the template

 

from py4web.core import Fixture

class InfoInjector(Fixture)

      def transform(self, output):

           if isinstance(output, dict) and 'info' not in output:

                output['info'] = get_info(auth)                                 
                    
           return output

 

@action('index')

@action.uses(auth, InfoInjector())

def index():

        return dict() # info is automatically injected

 

3) add logic directly to the template as in:

 

    [[from app.thisapp.common import get_info, auth]][[info = get_info(auth)]] 
... [[=info]]

 

I like solution 2 best

 

On Monday, 30 September 2019 09:50:07 UTC-7, John Bannister wrote:

Hi Massimo,

 

Not quite what I am after. Scenario which I have is that I have a number of 
different models each has a number of different atctions. I have a menu defined 
in layout.html which is included in each view. I would like to display the 
logged in user name in the menu (so something like Welcome John) if the user is 
logged in or LOGIN if they are not.

 

I understand that I can use auth.get_user in the action to access any auth user 
info I need but the question is do I need to pass back the user information to 
each and every view for layout.html to have access to the information or is 
there some way to set a global/application wide variable so that can be access 
by all views(templates). Ideally I would like to be able to access 
auth.get_user() from layout.html

 

BR

John

 

 

From: [email protected] [mailto:[email protected]] On Behalf Of 
Massimo Di Pierro
Sent: 30 September 2019 17:12
To: web2py-users
Subject: Re: [web2py] Re: py4web Auth

 

In any action decorated with @action.uses(auth.user) you can do

 

first_name = auth.get_user()['first_name']

 

Is this what you are asking?


On Monday, 30 September 2019 01:07:23 UTC-7, John Bannister wrote:

Hi Massimo,

 

Thanks very much. Will test and give you some feedback hopefully today.

 

Is there some sort of way to access user info from layout.html for example 
across multiple modules without having to pass the user from each eaction in 
each module? I want to be able to display the user name as part of the menu 
something like Welcome John (if the user is logged in) irrespective of module 
or action??

 

Best Regards

John

 

 

From: [email protected] [mailto:[email protected]] On Behalf Of 
Massimo Di Pierro
Sent: 30 September 2019 06:39
To: web2py-users
Subject: [web2py] Re: py4web Auth

 

I added a page to the documentation:

 

http://py4web.com/_documentation/static/index.html#chapter-11

 

I am sure it if full of spelling errors and I am making a fool of myself (my 
keyboard is acting up and my mother language is not english)

Also the examples could use an independent tester as I typed them without 
running them.

 

Anyway I thought this was better than nothing. :-)

 

Massimo

-- 
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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/e525e23a-199b-4b9b-83f6-ced97e1efaff%40googlegroups.com
 
<https://groups.google.com/d/msgid/web2py/e525e23a-199b-4b9b-83f6-ced97e1efaff%40googlegroups.com?utm_medium=email&utm_source=footer>
 .

-- 
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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/44a408dc-40cc-4bf7-b599-05b3f2b66289%40googlegroups.com
 
<https://groups.google.com/d/msgid/web2py/44a408dc-40cc-4bf7-b599-05b3f2b66289%40googlegroups.com?utm_medium=email&utm_source=footer>
 .

-- 
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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/5ba7b3b0-4b32-42c3-a4f7-9ad46607b4c9%40googlegroups.com
 
<https://groups.google.com/d/msgid/web2py/5ba7b3b0-4b32-42c3-a4f7-9ad46607b4c9%40googlegroups.com?utm_medium=email&utm_source=footer>
 .

-- 
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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/053001d5787c%2448841070%24d98c3150%24%40gmail.com.

Reply via email to