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: web2py@googlegroups.com [mailto:web2py@googlegroups.com] 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: web2py@googlegroups.com [mailto:web2py@googlegroups.com] 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 web2py+unsubscr...@googlegroups.com.
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 web2py+unsubscr...@googlegroups.com.
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 web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/045201d577af%241a0d7790%244e2866b0%24%40gmail.com.

Reply via email to